diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/color.js | 2 | ||||
-rw-r--r-- | src/svg.js | 24 |
2 files changed, 12 insertions, 14 deletions
diff --git a/src/color.js b/src/color.js index 1564bba..25f41d6 100644 --- a/src/color.js +++ b/src/color.js @@ -7,6 +7,8 @@ SVG.Color = function(color) { this.g = 0 this.b = 0 + if(!color) return + // parse color if (typeof color === 'string') { if (SVG.regex.isRgb.test(color)) { @@ -1,12 +1,7 @@ // The main wrapping element var SVG = this.SVG = function(element) { if (SVG.supported) { - element = new SVG.Doc(element) - - if (!SVG.parser) - SVG.prepare(element) - - return element + return new SVG.Doc(element) } } @@ -127,20 +122,21 @@ SVG.adopt = function(node) { } // Initialize parsing element -SVG.prepare = function(element) { +SVG.prepare = function() { // Select document body and create invisible svg element var body = document.getElementsByTagName('body')[0] - , draw = (body ? new SVG.Doc(body) : element.nested()).size(2, 0) - , path = SVG.create('path') - - // Insert parsers - draw.node.appendChild(path) + , draw = (body ? new SVG.Doc(body) : new SVG.Doc(document.documentElement).nested()).size(2, 0) // Create parser object SVG.parser = { - body: body || element.parent() + body: body || document.documentElement , draw: draw.style('opacity:0;position:fixed;left:100%;top:100%;overflow:hidden') , poly: draw.polyline().node - , path: path + , path: draw.path().node } } + +document.addEventListener('DOMContentLoaded', function() { + if(!SVG.parser) + SVG.prepare() +}, false) |