diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2017-07-28 14:20:48 +0200 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2017-07-28 14:20:48 +0200 |
commit | 6faf2c538a90e99e5fadd8662955466ba4ebe6f1 (patch) | |
tree | 86527be80ae580bad129a66366e5700ca75b83d5 /src/element.js | |
parent | ecea84ea3ae7f9986144c4fbd70994cfb9925654 (diff) | |
download | svg.js-6faf2c538a90e99e5fadd8662955466ba4ebe6f1.tar.gz svg.js-6faf2c538a90e99e5fadd8662955466ba4ebe6f1.zip |
The dom is checked for an svgjs:data attribute which is imported when creating an element
Diffstat (limited to 'src/element.js')
-rw-r--r-- | src/element.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/element.js b/src/element.js index 7c95156..c9b3fd7 100644 --- a/src/element.js +++ b/src/element.js @@ -12,6 +12,11 @@ SVG.Element = SVG.invent({ if (this.node = node) { this.type = node.nodeName this.node.instance = this + + if(node.hasAttribute('svgjs:data')) { + // pull svgjs data from the dom (getAttributeNS doesn't work in html5) + this.setData(JSON.parse(node.getAttribute('svgjs:data')) || {}) + } } } @@ -98,7 +103,7 @@ SVG.Element = SVG.invent({ if(typeof id == 'undefined' && !this.node.id) { this.node.id = SVG.eid(this.type) } - + // dont't set directly width this.node.id to make `null` work correctly return this.attr('id', id) } @@ -233,7 +238,7 @@ SVG.Element = SVG.invent({ } else { // write svgjs data to the dom this.writeDataToDom() - + return this.node.outerHTML } |