diff options
author | wout <wout@impinc.co.uk> | 2014-01-29 21:20:58 +0100 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2014-01-29 21:20:58 +0100 |
commit | 5b6736666dd85f8a063b87e6c6483ea47be4391c (patch) | |
tree | 139b35c98807ac36cad095af13ef45495958b78f /src/data.js | |
parent | 9688054367938f1e9240c2d8572e94bb0149bc77 (diff) | |
download | svg.js-5b6736666dd85f8a063b87e6c6483ea47be4391c.tar.gz svg.js-5b6736666dd85f8a063b87e6c6483ea47be4391c.zip |
Added SVG.PathArray, updated data() and bumped to v1.0rc1
Diffstat (limited to 'src/data.js')
-rw-r--r-- | src/data.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/data.js b/src/data.js new file mode 100644 index 0000000..1adbd52 --- /dev/null +++ b/src/data.js @@ -0,0 +1,29 @@ +// +SVG.extend(SVG.Element, { + // Store data values on svg nodes + data: function(a, v, r) { + if (typeof a == 'object') { + for (v in a) + this.data(v, a[v]) + + } else if (arguments.length < 2) { + try { + return JSON.parse(this.attr('data-' + a)) + } catch(e) { + return this.attr('data-' + a) + } + + } else { + this.attr( + 'data-' + a + , v === null ? + null : + r === true || typeof v === 'string' || typeof v === 'number' ? + v : + JSON.stringify(v) + ) + } + + return this + } +})
\ No newline at end of file |