aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2013-01-27 20:32:18 +0100
committerwout <wout@impinc.co.uk>2013-01-27 20:32:18 +0100
commitf636268a12039ececaaec14ad1fd3d2671799297 (patch)
tree565d8064f772759ff7c331fa4fc480abe8c2253c /src
parentb9981fd5c28d7282e6160ec7a32bcc3b103b9cf8 (diff)
downloadsvg.js-f636268a12039ececaaec14ad1fd3d2671799297.tar.gz
svg.js-f636268a12039ececaaec14ad1fd3d2671799297.zip
Simplifying data() method0.2
Diffstat (limited to 'src')
-rw-r--r--src/element.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/element.js b/src/element.js
index ab2a1e9..e1e69ec 100644
--- a/src/element.js
+++ b/src/element.js
@@ -204,8 +204,11 @@ SVG.extend(SVG.Element, {
// Store data values on svg nodes
data: function(a, v) {
if (arguments.length < 2) {
- var value = this.attr('data-' + a);
- try { return JSON.parse(value); } catch(e) { return value; };
+ try {
+ return JSON.parse(this.attr('data-' + a));
+ } catch(e) {
+ return this.attr('data-' + a);
+ };
} else {
v === null ?