summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2017-03-29 16:10:36 +0200
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2017-03-29 16:10:36 +0200
commitbb38273b6a2efd3795480cc36fa0ad0d67b73997 (patch)
tree146cc8f4fddb6d1203126546e0610077b42f4588 /src
parentebf7436261c8fc3197a48dc6b21dff9edd9271e3 (diff)
downloadsvg.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.js2
-rw-r--r--src/doc.js14
-rw-r--r--src/svg.js4
-rw-r--r--src/ungroup.js2
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{
diff --git a/src/doc.js b/src/doc.js
index caf0cc2..c6da348 100644
--- a/src/doc.js
+++ b/src/doc.js
@@ -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
+ }
}
})
diff --git a/src/svg.js b/src/svg.js
index 1f4a7e5..ee8832e 100644
--- a/src/svg.js
+++ b/src/svg.js
@@ -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