summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2013-01-27 20:17:17 +0100
committerwout <wout@impinc.co.uk>2013-01-27 20:17:17 +0100
commitfe1747c86d0e562853752ac2b412ed33cd109c4f (patch)
treeec56684826ca2053ab78d8ef7a29f0f1f1f1f6ae /src
parentb72373cf2fc024714825da95c59879ce9cbb4521 (diff)
downloadsvg.js-fe1747c86d0e562853752ac2b412ed33cd109c4f.tar.gz
svg.js-fe1747c86d0e562853752ac2b412ed33cd109c4f.zip
Added data() method
Diffstat (limited to 'src')
-rw-r--r--src/element.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/element.js b/src/element.js
index c23ea49..3130d73 100644
--- a/src/element.js
+++ b/src/element.js
@@ -201,6 +201,20 @@ SVG.extend(SVG.Element, {
/* add only te required transformations */
return this.attr('transform', transform.join(' '));
},
+ // Store data values on svg nodes
+ data: function(a, v) {
+ if (arguments.length < 2) {
+ var value = this.attr('data-' + a);
+ return value ? JSON.parse(value) : value;
+
+ } else {
+ v === null ?
+ this.node.removeAttribute('data-' + a) :
+ this.attr('data-' + a, JSON.stringify(v));
+ }
+
+ return this;
+ },
// Get bounding box
bbox: function() {
/* actual, native bounding box */