diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-11-06 13:48:05 +0100 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2018-11-06 13:48:05 +0100 |
commit | a0b13ebcacfd74b9f521110c7225bb404325bcd3 (patch) | |
tree | a07c5cc422645e31d7dfef81ce4e54f03f0945f6 /src/elements/Container.js | |
parent | 9f2696e8a2cf7e4eebc1cc7e31027fe2070094fa (diff) | |
download | svg.js-a0b13ebcacfd74b9f521110c7225bb404325bcd3.tar.gz svg.js-a0b13ebcacfd74b9f521110c7225bb404325bcd3.zip |
reordered modules, add es6 build
Diffstat (limited to 'src/elements/Container.js')
-rw-r--r-- | src/elements/Container.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/elements/Container.js b/src/elements/Container.js new file mode 100644 index 0000000..cdf8495 --- /dev/null +++ b/src/elements/Container.js @@ -0,0 +1,27 @@ +import Element from './Element.js' + +export default class Container extends Element { + flatten (parent) { + this.each(function () { + if (this instanceof Container) return this.flatten(parent).ungroup(parent) + return this.toParent(parent) + }) + + // we need this so that Doc does not get removed + this.node.firstElementChild || this.remove() + + return this + } + + ungroup (parent) { + parent = parent || this.parent() + + this.each(function () { + return this.toParent(parent) + }) + + this.remove() + + return this + } +} |