diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2016-01-21 17:40:13 +0100 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2016-01-21 17:40:13 +0100 |
commit | d17bab6bcccc8319b8b4c96db0def8926e93152d (patch) | |
tree | 408d6718f013499f86d7a4e4d0432122aef8cad8 /src | |
parent | ee027f30ffad52bdf0dbf3389cdc9c526118faf6 (diff) | |
download | svg.js-d17bab6bcccc8319b8b4c96db0def8926e93152d.tar.gz svg.js-d17bab6bcccc8319b8b4c96db0def8926e93152d.zip |
fixed `svgjs:data` attribute which was not set properly in all browsers (#428)
added specs for `writeDataToDom()` and `setData()`
added toJSON in SVG.Number
Diffstat (limited to 'src')
-rw-r--r-- | src/element.js | 2 | ||||
-rw-r--r-- | src/number.js | 3 | ||||
-rw-r--r-- | src/text.js | 2 |
3 files changed, 5 insertions, 2 deletions
diff --git a/src/element.js b/src/element.js index bd5d08d..090459f 100644 --- a/src/element.js +++ b/src/element.js @@ -247,7 +247,7 @@ SVG.Element = SVG.invent({ this.node.removeAttribute('svgjs:data') if(Object.keys(this.dom).length) - this.node.setAttributeNS(SVG.svgjs, 'svgjs:data', JSON.stringify(this.dom)) + this.node.setAttribute('svgjs:data', JSON.stringify(this.dom)) // see #428 return this } diff --git a/src/number.js b/src/number.js index 0ca8831..f0c53e0 100644 --- a/src/number.js +++ b/src/number.js @@ -48,6 +48,9 @@ SVG.Number = SVG.invent({ this.value ) + this.unit } + , toJSON: function() { + return this.toString() + } , // Convert to primitive valueOf: function() { return this.value diff --git a/src/text.js b/src/text.js index 79a4e1e..debc1fb 100644 --- a/src/text.js +++ b/src/text.js @@ -159,7 +159,7 @@ SVG.Text = SVG.invent({ // overwrite method from parent to set data properly , setData: function(o){ this.dom = o - this.dom.leading = o.leading ? new SVG.Number(o.leading.value, o.leading.unit) : new SVG.Number(1.3) + this.dom.leading = new SVG.Number(o.leading || 1.3) return this } } |