From 08c603beb7e3cb849c2cd66df6be536e97bba8e2 Mon Sep 17 00:00:00 2001 From: Andrea Bogazzi Date: Sat, 2 Jan 2021 20:09:02 +0100 Subject: [PATCH] fixed error in cacheProperties --- src/shapes/object.class.js | 1 - src/shapes/text.class.js | 10 +++++----- test/unit/text.js | 4 ++++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/shapes/object.class.js b/src/shapes/object.class.js index 4a1ed098559..e625e764925 100644 --- a/src/shapes/object.class.js +++ b/src/shapes/object.class.js @@ -991,7 +991,6 @@ this.group.set('dirty', true); } } - return this; }, diff --git a/src/shapes/text.class.js b/src/shapes/text.class.js index 6b04f136ae4..c098d9c6671 100644 --- a/src/shapes/text.class.js +++ b/src/shapes/text.class.js @@ -10,9 +10,9 @@ return; } - var styleProps = - 'fontFamily fontWeight fontSize text underline overline linethrough' + - ' textAlign fontStyle lineHeight textBackgroundColor charSpacing styles path'.split(' '); + var additionalProps = + ('fontFamily fontWeight fontSize text underline overline linethrough' + + ' textAlign fontStyle lineHeight textBackgroundColor charSpacing styles path').split(' '); /** * Text class @@ -172,13 +172,13 @@ * as well as for history (undo/redo) purposes * @type Array */ - stateProperties: fabric.Object.prototype.stateProperties.concat(styleProps), + stateProperties: fabric.Object.prototype.stateProperties.concat(additionalProps), /** * List of properties to consider when checking if cache needs refresh * @type Array */ - cacheProperties: fabric.Object.prototype.cacheProperties.concat(styleProps), + cacheProperties: fabric.Object.prototype.cacheProperties.concat(additionalProps), /** * When defined, an object is rendered via stroke and this property specifies its color. diff --git a/test/unit/text.js b/test/unit/text.js index 3e193c5e308..da5370fe324 100644 --- a/test/unit/text.js +++ b/test/unit/text.js @@ -841,5 +841,9 @@ assert.equal(text.height, 100, 'text is big as the path height'); }); + QUnit.test('cacheProperties for text', function(assert) { + var text = new fabric.Text('a'); + assert.equal(text.cacheProperties.join('-'), 'fill-stroke-strokeWidth-strokeDashArray-width-height-paintFirst-strokeUniform-strokeLineCap-strokeDashOffset-strokeLineJoin-strokeMiterLimit-backgroundColor-clipPath-fontFamily-fontWeight-fontSize-text-underline-overline-linethrough-textAlign-fontStyle-lineHeight-textBackgroundColor-charSpacing-styles-path'); + }); })();