summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
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 */