diff options
Diffstat (limited to 'src')
-rwxr-xr-x | src/svg.js | 29 |
1 files changed, 16 insertions, 13 deletions
@@ -8,6 +8,9 @@ // The main wrapping element this.SVG = function(element) { + if (!SVG.parser) + SVG.prepare() + if (SVG.supported) return new SVG.Doc(element) } @@ -56,22 +59,14 @@ SVG.extend = function() { SVG.Set.inherit() } -// Method for getting an eleemnt by id +// Method for getting an element by id SVG.get = function(id) { var node = document.getElementById(id) if (node) return node.instance } -// svg support test -SVG.supported = (function() { - return !! document.createElementNS && - !! document.createElementNS(SVG.ns,'svg').createSVGRect -})() - -if (!SVG.supported) return false - // Initialize parsing element -SVG.parser = (function() { +SVG.prepare = function() { /* select document body and create svg element*/ var body = document.getElementsByTagName('body')[0] || document.getElementsByTagName('svg')[0] , svg = SVG.create('svg') @@ -89,12 +84,20 @@ SVG.parser = (function() { svg.appendChild(poly) svg.appendChild(path) - /* return parser object */ - return { + /* create parser object */ + SVG.parser = { body: body , doc: svg , poly: poly , path: path } -})()
\ No newline at end of file +} + +// svg support test +SVG.supported = (function() { + return !! document.createElementNS && + !! document.createElementNS(SVG.ns,'svg').createSVGRect +})() + +if (!SVG.supported) return false
\ No newline at end of file |