Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include textBackgroundColor check in hasStyleChanged #8365

Merged
merged 2 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/util/misc/textStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const hasStyleChanged = (
prevStyle.fontFamily !== thisStyle.fontFamily ||
prevStyle.fontWeight !== thisStyle.fontWeight ||
prevStyle.fontStyle !== thisStyle.fontStyle ||
prevStyle.textBackgroundColor !== thisStyle.textBackgroundColor ||
prevStyle.deltaY !== thisStyle.deltaY ||
(forTextSpans &&
(prevStyle.overline !== thisStyle.overline ||
Expand Down
7 changes: 7 additions & 0 deletions test/unit/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,13 @@
assert.deepEqual(obj.styles, [], 'empty style object has been removed');
});

QUnit.test('text toObject can handle style objects with only a textBackgroundColor property', function(assert) {
var text = new fabric.Text('xxx');
text.styles = { 0: { 0: { textBackgroundColor: 'blue' } } };
var obj = text.toObject();
assert.deepEqual(obj.styles, [{ start: 0, end: 1, style: { textBackgroundColor: 'blue' }}], 'empty style object has been removed');
melchiar marked this conversation as resolved.
Show resolved Hide resolved
});

QUnit.test('getFontCache works with fontWeight numbers', function(assert) {
var text = new fabric.Text('xxx', { fontWeight: 400 });
text.initDimensions();
Expand Down