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 all commits
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [next]

- fix(textStyles): Handle style objects with only a textBackgroundColor property in stylesToArray [#8365](https://github.com/fabricjs/fabric.js/pull/8365)
- chore(): fix typos in intersection file [#8345](https://github.com/fabricjs/fabric.js/pull/8345)
- fix(textStyles): Handle empty style object in stylesToArray [#8357](https://github.com/fabricjs/fabric.js/pull/8357)
- ci(build): safeguard concurrent unlocking [#8309](https://github.com/fabricjs/fabric.js/pull/8309)
Expand Down
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
11 changes: 11 additions & 0 deletions test/unit/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,17 @@
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' }}],
'styles with only a textBackgroundColor property do not throw an error'
);
});

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