diff options
author | wout <wout@impinc.co.uk> | 2013-01-27 20:17:17 +0100 |
---|---|---|
committer | wout <wout@impinc.co.uk> | 2013-01-27 20:17:17 +0100 |
commit | fe1747c86d0e562853752ac2b412ed33cd109c4f (patch) | |
tree | ec56684826ca2053ab78d8ef7a29f0f1f1f1f6ae /dist/svg.js | |
parent | b72373cf2fc024714825da95c59879ce9cbb4521 (diff) | |
download | svg.js-fe1747c86d0e562853752ac2b412ed33cd109c4f.tar.gz svg.js-fe1747c86d0e562853752ac2b412ed33cd109c4f.zip |
Added data() method
Diffstat (limited to 'dist/svg.js')
-rw-r--r-- | dist/svg.js | 16 |
1 files changed, 15 insertions, 1 deletions
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 */ |