aboutsummaryrefslogtreecommitdiffstats
path: root/src/element.js
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2017-04-23 12:52:51 +0200
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2017-04-23 12:52:51 +0200
commit54362a872c75efa2f54be755a1a48ab87ab3e836 (patch)
tree3c96ade60a6726f75ee8dfe267550c728214e7bb /src/element.js
parentab1c07e80bd21f2cdf773be238d4dd754db4e80a (diff)
downloadsvg.js-54362a872c75efa2f54be755a1a48ab87ab3e836.tar.gz
svg.js-54362a872c75efa2f54be755a1a48ab87ab3e836.zip
ids are not generated upon creation anymore
Instead they are generated when requested (#559)
Diffstat (limited to 'src/element.js')
-rw-r--r--src/element.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/element.js b/src/element.js
index 1e3dcb0..cedaf2d 100644
--- a/src/element.js
+++ b/src/element.js
@@ -58,7 +58,7 @@ SVG.Element = SVG.invent({
.height(new SVG.Number(p.height))
}
// Clone element
- , clone: function(parent, withData) {
+ , clone: function(parent) {
// write dom data to the dom so the clone can pickup the data
this.writeDataToDom()
@@ -94,6 +94,12 @@ SVG.Element = SVG.invent({
}
// Get / set id
, id: function(id) {
+ // generate new id if no id set
+ if(typeof id == 'undefined' && !this.node.id) {
+ this.node.id = SVG.eid(this.type)
+ }
+
+ // dont't set directly width this.node.id to make `null` work correctly
return this.attr('id', id)
}
// Checks whether the given point inside the bounding box of the element
@@ -119,7 +125,7 @@ SVG.Element = SVG.invent({
}
// Return id on string conversion
, toString: function() {
- return this.attr('id')
+ return this.id()
}
// Return array of classes on the node
, classes: function() {