From fe1747c86d0e562853752ac2b412ed33cd109c4f Mon Sep 17 00:00:00 2001 From: wout Date: Sun, 27 Jan 2013 20:17:17 +0100 Subject: Added data() method --- dist/svg.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'dist/svg.js') diff --git a/dist/svg.js b/dist/svg.js index b57af02..e319460 100644 --- a/dist/svg.js +++ b/dist/svg.js @@ -1,4 +1,4 @@ -/* svg.js v0.1-87-g6ae4977 - svg container element fx event group arrange defs mask pattern gradient doc shape wrap rect ellipse poly path image text nested sugar - svgjs.com/license */ +/* svg.js v0.1-88-gb72373c - svg container element fx event group arrange defs mask pattern gradient doc shape wrap rect ellipse poly path image text nested sugar - svgjs.com/license */ (function() { this.svg = function(element) { @@ -355,6 +355,20 @@ /* 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 */ -- cgit v1.2.3