summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2016-04-01 23:57:02 +0200
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2016-04-01 23:57:02 +0200
commite059cf7f0a9b6325baad21c4fb47f0ec632088ca (patch)
tree3f19b6ef800655095853256e5ecb4d8e877c5185 /src
parentb006c02b219fea7af04b764ab2fd6c4b55a8c4ac (diff)
downloadsvg.js-e059cf7f0a9b6325baad21c4fb47f0ec632088ca.tar.gz
svg.js-e059cf7f0a9b6325baad21c4fb47f0ec632088ca.zip
fix parser error (#471) and small bug in SVG.Color with new fx
Diffstat (limited to 'src')
-rw-r--r--src/color.js2
-rw-r--r--src/svg.js24
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)) {
diff --git a/src/svg.js b/src/svg.js
index c69aebc..4cdf364 100644
--- a/src/svg.js
+++ b/src/svg.js
@@ -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)