summaryrefslogtreecommitdiffstats
path: root/src/element.js
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2017-07-25 09:14:48 +0200
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2017-07-25 09:14:48 +0200
commitd6d389133409b315bc1b74752f58ef2647033bb9 (patch)
treec64c68abeef515ed1dc20a402d304b4609d8767e /src/element.js
parentbc9bfb6025e826b0ee6c827f1a356995d7f05d4c (diff)
downloadsvg.js-d6d389133409b315bc1b74752f58ef2647033bb9.tar.gz
svg.js-d6d389133409b315bc1b74752f58ef2647033bb9.zip
Lots of breaking changes. Read below! (#646, #716)
- added `SVG.HTMLNode` which is the object wrapped around html nodes to put something in them - moved `defs()` method from `SVG.Parent` to `SVG.Element` - `SVG()` can be called with css selector, node or svg string, now. Without an argument it creates a new `SVG.Doc()` (#646) - `add()`, `put()`, `addTo()`, `putIn()` now excepts all arguments accepted by `SVG()` - `SVG.Nested` is not `overflow:visible` by default - all `SVG.*` objects now can have a node as parameter when constructing - `SVG()` does not set a default size anymore
Diffstat (limited to 'src/element.js')
-rw-r--r--src/element.js11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/element.js b/src/element.js
index a4eda1f..7c95156 100644
--- a/src/element.js
+++ b/src/element.js
@@ -86,11 +86,11 @@ SVG.Element = SVG.invent({
}
// Add element to given container and return self
, addTo: function(parent) {
- return parent.put(this)
+ return createElement(parent).put(this)
}
// Add element to given container and return container
, putIn: function(parent) {
- return parent.add(this)
+ return createElement(parent).add(this)
}
// Get / set id
, id: function(id) {
@@ -187,6 +187,10 @@ SVG.Element = SVG.invent({
, doc: function() {
return this instanceof SVG.Doc ? this : this.parent(SVG.Doc)
}
+ , // Get defs
+ defs: function() {
+ return this.doc().defs()
+ }
// return array of all ancestors of given type up to the root svg
, parents: function(type) {
var parents = [], parent = this
@@ -227,6 +231,9 @@ SVG.Element = SVG.invent({
// otherwise act as a getter
} else {
+ // write svgjs data to the dom
+ this.writeDataToDom()
+
return this.node.outerHTML
}