summaryrefslogtreecommitdiffstats
path: root/src/doc.js
diff options
context:
space:
mode:
authorwout <wout@impinc.co.uk>2013-03-29 13:40:19 +0000
committerwout <wout@impinc.co.uk>2013-03-29 13:40:19 +0000
commitf134e1cf3d06804f42c08e7e7985a5ab59a82c5c (patch)
tree55715ecce60fe1701d8c8723f0f056e579836c1b /src/doc.js
parent089816c84f8ae573cf558fe3b0242847f9eacbe9 (diff)
downloadsvg.js-f134e1cf3d06804f42c08e7e7985a5ab59a82c5c.tar.gz
svg.js-f134e1cf3d06804f42c08e7e7985a5ab59a82c5c.zip
Allow invocation of SVG() with an <svg> tag
Diffstat (limited to 'src/doc.js')
-rw-r--r--src/doc.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/doc.js b/src/doc.js
index 2e2fd0a..cedaefe 100644
--- a/src/doc.js
+++ b/src/doc.js
@@ -2,21 +2,23 @@
//
SVG.Doc = function(element) {
- this.constructor.call(this, SVG.create('svg'))
-
/* ensure the presence of a html element */
this.parent = typeof element == 'string' ?
document.getElementById(element) :
element
/* set svg element attributes and create the <defs> node */
+ this.constructor
+ .call(this, this.parent.nodeName == 'svg' ? this.parent : SVG.create('svg'))
+
this
.attr({ xmlns: SVG.ns, version: '1.1', width: '100%', height: '100%' })
.attr('xlink', SVG.xlink, SVG.ns)
.defs()
/* ensure correct rendering for safari */
- this.stage()
+ if (this.parent.nodeName != 'svg')
+ this.stage()
}
// Inherits from SVG.Container