diff options
author | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2017-03-29 16:10:36 +0200 |
---|---|---|
committer | Ulrich-Matthias Schäfer <ulima.ums@googlemail.com> | 2017-03-29 16:10:36 +0200 |
commit | bb38273b6a2efd3795480cc36fa0ad0d67b73997 (patch) | |
tree | 146cc8f4fddb6d1203126546e0610077b42f4588 /src | |
parent | ebf7436261c8fc3197a48dc6b21dff9edd9271e3 (diff) | |
download | svg.js-bb38273b6a2efd3795480cc36fa0ad0d67b73997.tar.gz svg.js-bb38273b6a2efd3795480cc36fa0ad0d67b73997.zip |
clear does not remove parser anymore
make test work in svg documents
Diffstat (limited to 'src')
-rw-r--r-- | src/boxes.js | 2 | ||||
-rw-r--r-- | src/doc.js | 14 | ||||
-rw-r--r-- | src/svg.js | 4 | ||||
-rw-r--r-- | src/ungroup.js | 2 |
4 files changed, 18 insertions, 4 deletions
diff --git a/src/boxes.js b/src/boxes.js index 60e9b5d..dd6003b 100644 --- a/src/boxes.js +++ b/src/boxes.js @@ -87,7 +87,7 @@ SVG.BBox = SVG.invent({ box = element.node.getBBox() } catch(e) { if(element instanceof SVG.Shape){ - var clone = element.clone(SVG.parser.draw).show() + var clone = element.clone(SVG.parser.draw.instance).show() box = clone.node.getBBox() clone.remove() }else{ @@ -76,6 +76,20 @@ SVG.Doc = SVG.invent({ return this; } + , clear: function() { + // remove children + while(this.node.hasChildNodes()) + this.node.removeChild(this.node.lastChild) + + // remove defs reference + delete this._defs + + // add back parser + if(!SVG.parser.draw.parentNode) + this.node.appendChild(SVG.parser.draw) + + return this + } } }) @@ -130,12 +130,12 @@ SVG.adopt = function(node) { SVG.prepare = function() { // Select document body and create invisible svg element var body = document.getElementsByTagName('body')[0] - , draw = (body ? new SVG.Doc(body) : SVG.adopt(document.documentElement).nested()).size(2, 0) + , draw = (body ? new SVG.Doc(body) : SVG.adopt(document.documentElement).nested()).size(2, 0) // Create parser object SVG.parser = { body: body || document.documentElement - , draw: draw.style('opacity:0;position:absolute;left:-100%;top:-100%;overflow:hidden') + , draw: draw.style('opacity:0;position:absolute;left:-100%;top:-100%;overflow:hidden').node , poly: draw.polyline().node , path: draw.path().node , native: SVG.create('svg') diff --git a/src/ungroup.js b/src/ungroup.js index 7f26915..a76a5a6 100644 --- a/src/ungroup.js +++ b/src/ungroup.js @@ -1,7 +1,7 @@ SVG.extend(SVG.Parent, { ungroup: function(parent, depth) { - if(depth === 0 || this instanceof SVG.Defs) return this + if(depth === 0 || this instanceof SVG.Defs || this.node == SVG.parser.draw) return this parent = parent || (this instanceof SVG.Doc ? this : this.parent(SVG.Parent)) depth = depth || Infinity |