summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2014-06-21 20:32:28 +0200
committerwout <wout@impinc.co.uk>2014-06-21 20:32:28 +0200
commit629a01b3bbf057eae7e0599433bbbcb28acd8587 (patch)
treec6ce43e4bb28e61885921d19ae99726ea93828c0 /src
parent19b6fd4338246d1fd9ca4806e57c7aebcec63826 (diff)
downloadsvg.js-629a01b3bbf057eae7e0599433bbbcb28acd8587.tar.gz
svg.js-629a01b3bbf057eae7e0599433bbbcb28acd8587.zip
Various reference fixes
Diffstat (limited to 'src')
-rwxr-xr-xsrc/doc.js3
-rwxr-xr-xsrc/parent.js11
-rwxr-xr-xsrc/rbox.js2
3 files changed, 9 insertions, 7 deletions
diff --git a/src/doc.js b/src/doc.js
index 54b7c70..1a025f3 100755
--- a/src/doc.js
+++ b/src/doc.js
@@ -15,10 +15,11 @@ SVG.Doc = SVG.invent({
element.appendChild(this.node)
}
- /* set svg element attributes */
+ /* set svg element attributes and ensure defs node */
this
.attr({ xmlns: SVG.ns, version: '1.1', width: '100%', height: '100%' })
.attr('xmlns:xlink', SVG.xlink, SVG.xmlns)
+ .defs()
}
// Inherit from
diff --git a/src/parent.js b/src/parent.js
index 55878ec..095120a 100755
--- a/src/parent.js
+++ b/src/parent.js
@@ -18,10 +18,10 @@ SVG.Parent = SVG.invent({
// Add given element at a position
, add: function(element, i) {
if (!this.has(element)) {
- /* define insertion index if none given */
+ // Define insertion index if none given
i = i == null ? this.children().length : i
- /* add element references */
+ // Add element references
this.node.insertBefore(element.node, this.node.childNodes[i] || null)
}
@@ -78,9 +78,10 @@ SVG.Parent = SVG.invent({
// Remove children
while(this.node.hasChildNodes())
this.node.removeChild(this.node.lastChild)
-
- // Remove defs cache reference
- delete this._defs
+
+ // Ensure new defs node
+ if (this instanceof SVG.Doc)
+ this.defs()
return this
}
diff --git a/src/rbox.js b/src/rbox.js
index 598b3b4..fe6a9fa 100755
--- a/src/rbox.js
+++ b/src/rbox.js
@@ -31,7 +31,7 @@ SVG.RBox = function(element) {
/* calculate cumulative zoom from svg documents */
e = element
- while (e = e.parent()) {
+ while (e.parent && (e = e.parent())) {
if (e.type == 'svg' && e.viewbox) {
zoom *= e.viewbox().zoom
this.x -= e.x() || 0