diff --git a/src/shapes/text.class.js b/src/shapes/text.class.js index e8489c9ad7d..68d97a78e5d 100644 --- a/src/shapes/text.class.js +++ b/src/shapes/text.class.js @@ -12,7 +12,8 @@ var additionalProps = ('fontFamily fontWeight fontSize text underline overline linethrough' + - ' textAlign fontStyle lineHeight textBackgroundColor charSpacing styles path').split(' '); + ' textAlign fontStyle lineHeight textBackgroundColor charSpacing styles' + + ' direction path pathStartOffset pathSide').split(' '); /** * Text class @@ -39,7 +40,9 @@ 'charSpacing', 'textAlign', 'styles', - 'path' + 'path', + 'pathStartOffset', + 'pathSide' ], /** @@ -1500,25 +1503,13 @@ * @return {Object} Object representation of an instance */ toObject: function(propertiesToInclude) { - var additionalProperties = [ - 'text', - 'fontSize', - 'fontWeight', - 'fontFamily', - 'fontStyle', - 'lineHeight', - 'underline', - 'overline', - 'linethrough', - 'textAlign', - 'textBackgroundColor', - 'charSpacing', - 'path', - 'direction', - ].concat(propertiesToInclude); - var obj = this.callSuper('toObject', additionalProperties); + var allProperties = additionalProps.concat(propertiesToInclude); + var obj = this.callSuper('toObject', allProperties); + // styles will be overridden with a properly cloned structure obj.styles = clone(this.styles, true); - obj.path = this.path && this.path.toObject(); + if (obj.path) { + obj.path = this.path.toObject(); + } return obj; }, diff --git a/test/unit/itext.js b/test/unit/itext.js index 71791255c5c..63ee979ad83 100644 --- a/test/unit/itext.js +++ b/test/unit/itext.js @@ -48,6 +48,8 @@ strokeUniform: false, path: null, direction: 'ltr', + pathStartOffset: 0, + pathSide: 'left', }; diff --git a/test/unit/text.js b/test/unit/text.js index 1a578ea89f3..45fb64bbad3 100644 --- a/test/unit/text.js +++ b/test/unit/text.js @@ -55,6 +55,8 @@ path: null, strokeUniform: false, direction: 'ltr', + pathStartOffset: 0, + pathSide: 'left', }; QUnit.test('constructor', function(assert) { @@ -867,7 +869,7 @@ 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'); + 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-direction-path-pathStartOffset-pathSide'); }); QUnit.test('_getLineLeftOffset', function(assert) { diff --git a/test/unit/textbox.js b/test/unit/textbox.js index 9fc45b82dbd..f50d411f713 100644 --- a/test/unit/textbox.js +++ b/test/unit/textbox.js @@ -55,6 +55,8 @@ strokeUniform: false, path: null, direction: 'ltr', + pathStartOffset: 0, + pathSide: 'left', }; QUnit.test('constructor', function(assert) {