Fix for bug #111

master
Dmitry Baranovskiy 2013-11-20 18:07:47 +11:00
parent 74cbaf763b
commit 1ae1f20d48
5 changed files with 47 additions and 35 deletions

File diff suppressed because one or more lines are too long

16
dist/snap.svg.js vendored
View File

@ -2027,8 +2027,8 @@ function getSomeDefs(el) {
if (cache && contains(cache.ownerDocument.documentElement, cache)) {
return cache;
}
var p = el.paper ||
(el.node.parentNode && Snap(el.node.parentNode)) ||
var p = (el.node.ownerSVGElement && wrap(el.node.ownerSVGElement)) ||
(el.node.parentNode && wrap(el.node.parentNode)) ||
Snap.select("svg") ||
Snap(0, 0),
defs = p.select("defs").node;
@ -3086,8 +3086,14 @@ Snap.parse = function (svg) {
}
div.innerHTML = svg;
svg = div.getElementsByTagName("svg")[0];
while (svg && svg.firstChild) {
f.appendChild(svg.firstChild);
if (svg) {
if (full) {
f = svg;
} else {
while (svg.firstChild) {
f.appendChild(svg.firstChild);
}
}
}
div.innerHTML = E;
return new Fragment(f);
@ -5979,7 +5985,7 @@ Snap.plugin(function (Snap, Element, Paper, glob) {
};
}
var aUnit = a.match(reUnit),
bUnit = b.match(reUnit);
bUnit = Str(b).match(reUnit);
if (aUnit && aUnit == bUnit) {
return {
from: parseFloat(a),

View File

@ -5709,7 +5709,7 @@ If key is not provided, removes all the data of the element.
<article id="Fragment.select">
<header>
<h3 class="dr-method">Fragment.select()<a href="#Fragment.select" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2356 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2356">&#x27ad;</a></h3>
<h3 class="dr-method">Fragment.select()<a href="#Fragment.select" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2362 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2362">&#x27ad;</a></h3>
</header>
<section>
<div class="extra" id="Fragment.select-extra"></div>
@ -5734,7 +5734,7 @@ If key is not provided, removes all the data of the element.
<article id="Fragment.selectAll">
<header>
<h3 class="dr-method">Fragment.selectAll()<a href="#Fragment.selectAll" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2363 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2363">&#x27ad;</a></h3>
<h3 class="dr-method">Fragment.selectAll()<a href="#Fragment.selectAll" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2369 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2369">&#x27ad;</a></h3>
</header>
<section>
<div class="extra" id="Fragment.selectAll-extra"></div>
@ -5759,7 +5759,7 @@ If key is not provided, removes all the data of the element.
<article id="Snap.fragment">
<header>
<h3 class="dr-method">Snap.fragment(varargs)<a href="#Snap.fragment" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2374 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2374">&#x27ad;</a></h3>
<h3 class="dr-method">Snap.fragment(varargs)<a href="#Snap.fragment" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2380 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2380">&#x27ad;</a></h3>
</header>
<section>
<div class="extra" id="Snap.fragment-extra"></div>
@ -5819,7 +5819,7 @@ If key is not provided, removes all the data of the element.
<article id="Paper.el">
<header>
<h3 class="dr-method">Paper.el(name, attr)<a href="#Paper.el" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2575 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2575">&#x27ad;</a></h3>
<h3 class="dr-method">Paper.el(name, attr)<a href="#Paper.el" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2581 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2581">&#x27ad;</a></h3>
</header>
<section>
<div class="extra" id="Paper.el-extra"></div>
@ -5909,7 +5909,7 @@ var c = paper.el("circle").attr({
<article id="Paper.rect">
<header>
<h3 class="dr-method">Paper.rect(x, y, width, height, [rx], [ry])<a href="#Paper.rect" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2598 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2598">&#x27ad;</a></h3>
<h3 class="dr-method">Paper.rect(x, y, width, height, [rx], [ry])<a href="#Paper.rect" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2604 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2604">&#x27ad;</a></h3>
</header>
<section>
<div class="extra" id="Paper.rect-extra"></div>
@ -6009,7 +6009,7 @@ var c = paper.rect(40, 40, 50, 50, 10);</code></pre></section>
<article id="Paper.circle">
<header>
<h3 class="dr-method">Paper.circle(x, y, r)<a href="#Paper.circle" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2635 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2635">&#x27ad;</a></h3>
<h3 class="dr-method">Paper.circle(x, y, r)<a href="#Paper.circle" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2641 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2641">&#x27ad;</a></h3>
</header>
<section>
<div class="extra" id="Paper.circle-extra"></div>
@ -6097,7 +6097,7 @@ var c = paper.rect(40, 40, 50, 50, 10);</code></pre></section>
<article id="Paper.image">
<header>
<h3 class="dr-method">Paper.image(src, x, y, width, height)<a href="#Paper.image" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2667 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2667">&#x27ad;</a></h3>
<h3 class="dr-method">Paper.image(src, x, y, width, height)<a href="#Paper.image" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2673 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2673">&#x27ad;</a></h3>
</header>
<section>
<div class="extra" id="Paper.image-extra"></div>
@ -6219,7 +6219,7 @@ var c = paper.rect(40, 40, 50, 50, 10);</code></pre></section>
<article id="Paper.ellipse">
<header>
<h3 class="dr-method">Paper.ellipse(x, y, rx, ry)<a href="#Paper.ellipse" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2710 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2710">&#x27ad;</a></h3>
<h3 class="dr-method">Paper.ellipse(x, y, rx, ry)<a href="#Paper.ellipse" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2716 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2716">&#x27ad;</a></h3>
</header>
<section>
<div class="extra" id="Paper.ellipse-extra"></div>
@ -6310,7 +6310,7 @@ var c = paper.rect(40, 40, 50, 50, 10);</code></pre></section>
<article id="Paper.path">
<header>
<h3 class="dr-method">Paper.path([pathString])<a href="#Paper.path" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2755 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2755">&#x27ad;</a></h3>
<h3 class="dr-method">Paper.path([pathString])<a href="#Paper.path" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2761 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2761">&#x27ad;</a></h3>
</header>
<section>
<div class="extra" id="Paper.path-extra"></div>
@ -6578,7 +6578,7 @@ Note: there is a special case when a path consists of only three commands: <code
<article id="Paper.g">
<header>
<h3 class="dr-method">Paper.g([varargs])<a href="#Paper.g" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2786 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2786">&#x27ad;</a></h3>
<h3 class="dr-method">Paper.g([varargs])<a href="#Paper.g" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2792 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2792">&#x27ad;</a></h3>
</header>
<section>
<div class="extra" id="Paper.g-extra"></div>
@ -6687,7 +6687,7 @@ g.add(c2, c1);</code></pre></section>
<article id="Paper.group">
<header>
<h3 class="dr-method">Paper.group()<a href="#Paper.group" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2792 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2792">&#x27ad;</a></h3>
<h3 class="dr-method">Paper.group()<a href="#Paper.group" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2798 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2798">&#x27ad;</a></h3>
</header>
<section>
<div class="extra" id="Paper.group-extra"></div>
@ -6712,7 +6712,7 @@ g.add(c2, c1);</code></pre></section>
<article id="Paper.text">
<header>
<h3 class="dr-method">Paper.text(x, y, text)<a href="#Paper.text" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2820 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2820">&#x27ad;</a></h3>
<h3 class="dr-method">Paper.text(x, y, text)<a href="#Paper.text" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2826 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2826">&#x27ad;</a></h3>
</header>
<section>
<div class="extra" id="Paper.text-extra"></div>
@ -6801,7 +6801,7 @@ var t2 = paper.text(50, 50, ["S","n","a","p"]);</code></pre></section>
<article id="Paper.line">
<header>
<h3 class="dr-method">Paper.line(x1, y1, x2, y2)<a href="#Paper.line" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2848 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2848">&#x27ad;</a></h3>
<h3 class="dr-method">Paper.line(x1, y1, x2, y2)<a href="#Paper.line" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2854 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2854">&#x27ad;</a></h3>
</header>
<section>
<div class="extra" id="Paper.line-extra"></div>
@ -6892,7 +6892,7 @@ var t2 = paper.text(50, 50, ["S","n","a","p"]);</code></pre></section>
<article id="Paper.polyline">
<header>
<h3 class="dr-method">Paper.polyline(…)<a href="#Paper.polyline" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2877 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2877">&#x27ad;</a></h3>
<h3 class="dr-method">Paper.polyline(…)<a href="#Paper.polyline" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2883 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2883">&#x27ad;</a></h3>
</header>
<section>
<div class="extra" id="Paper.polyline-extra"></div>
@ -7004,7 +7004,7 @@ var p2 = paper.polyline(10, 10, 100, 100);</code></pre></section>
<article id="Paper.polygon">
<header>
<h3 class="dr-method">Paper.polygon()<a href="#Paper.polygon" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2897 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2897">&#x27ad;</a></h3>
<h3 class="dr-method">Paper.polygon()<a href="#Paper.polygon" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2903 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2903">&#x27ad;</a></h3>
</header>
<section>
<div class="extra" id="Paper.polygon-extra"></div>
@ -7029,7 +7029,7 @@ var p2 = paper.polyline(10, 10, 100, 100);</code></pre></section>
<article id="Paper.gradient">
<header>
<h3 class="dr-method">Paper.gradient(gradient)<a href="#Paper.gradient" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2950 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2950">&#x27ad;</a></h3>
<h3 class="dr-method">Paper.gradient(gradient)<a href="#Paper.gradient" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2956 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2956">&#x27ad;</a></h3>
</header>
<section>
<div class="extra" id="Paper.gradient-extra"></div>
@ -7227,7 +7227,7 @@ half the width, from black to white:
<article id="Paper.toString">
<header>
<h3 class="dr-method">Paper.toString()<a href="#Paper.toString" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2966 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2966">&#x27ad;</a></h3>
<h3 class="dr-method">Paper.toString()<a href="#Paper.toString" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2972 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2972">&#x27ad;</a></h3>
</header>
<section>
<div class="extra" id="Paper.toString-extra"></div>
@ -7269,7 +7269,7 @@ half the width, from black to white:
<article id="Paper.clear">
<header>
<h3 class="dr-method">Paper.clear()<a href="#Paper.clear" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2984 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2984">&#x27ad;</a></h3>
<h3 class="dr-method">Paper.clear()<a href="#Paper.clear" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 2990 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#2990">&#x27ad;</a></h3>
</header>
<section>
<div class="extra" id="Paper.clear-extra"></div>
@ -7294,7 +7294,7 @@ half the width, from black to white:
<article id="Snap.ajax">
<header>
<h3 class="dr-method">Snap.ajax(…)<a href="#Snap.ajax" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 3015 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#3015">&#x27ad;</a></h3>
<h3 class="dr-method">Snap.ajax(…)<a href="#Snap.ajax" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 3021 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#3021">&#x27ad;</a></h3>
</header>
<section>
<div class="extra" id="Snap.ajax-extra"></div>
@ -7398,7 +7398,7 @@ half the width, from black to white:
<article id="Snap.load">
<header>
<h3 class="dr-method">Snap.load(url, callback, [scope])<a href="#Snap.load" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 3061 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#3061">&#x27ad;</a></h3>
<h3 class="dr-method">Snap.load(url, callback, [scope])<a href="#Snap.load" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 3067 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#3067">&#x27ad;</a></h3>
</header>
<section>
<div class="extra" id="Snap.load-extra"></div>
@ -7447,7 +7447,7 @@ half the width, from black to white:
<article id="Snap.getElementByPoint">
<header>
<h3 class="dr-method">Snap.getElementByPoint(x, y)<a href="#Snap.getElementByPoint" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 3490 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#3490">&#x27ad;</a></h3>
<h3 class="dr-method">Snap.getElementByPoint(x, y)<a href="#Snap.getElementByPoint" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 3496 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#3496">&#x27ad;</a></h3>
</header>
<section>
<div class="extra" id="Snap.getElementByPoint-extra"></div>
@ -7532,7 +7532,7 @@ half the width, from black to white:
<article id="Snap.plugin">
<header>
<h3 class="dr-method">Snap.plugin(f)<a href="#Snap.plugin" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 3525 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#3525">&#x27ad;</a></h3>
<h3 class="dr-method">Snap.plugin(f)<a href="#Snap.plugin" title="Link to this section" class="dr-hash">&#x2693;</a><a class="dr-sourceline" title="Go to line 3531 in the source" href="https://github.com/adobe-webplatform/savage/blob/master/src/svg.js#3531">&#x27ad;</a></h3>
</header>
<section>
<div class="extra" id="Snap.plugin-extra"></div>

View File

@ -137,7 +137,7 @@ Snap.plugin(function (Snap, Element, Paper, glob) {
};
}
var aUnit = a.match(reUnit),
bUnit = b.match(reUnit);
bUnit = Str(b).match(reUnit);
if (aUnit && aUnit == bUnit) {
return {
from: parseFloat(a),

View File

@ -1279,8 +1279,8 @@ function getSomeDefs(el) {
if (cache && contains(cache.ownerDocument.documentElement, cache)) {
return cache;
}
var p = el.paper ||
(el.node.parentNode && Snap(el.node.parentNode)) ||
var p = (el.node.ownerSVGElement && wrap(el.node.ownerSVGElement)) ||
(el.node.parentNode && wrap(el.node.parentNode)) ||
Snap.select("svg") ||
Snap(0, 0),
defs = p.select("defs").node;
@ -2338,8 +2338,14 @@ Snap.parse = function (svg) {
}
div.innerHTML = svg;
svg = div.getElementsByTagName("svg")[0];
while (svg && svg.firstChild) {
f.appendChild(svg.firstChild);
if (svg) {
if (full) {
f = svg;
} else {
while (svg.firstChild) {
f.appendChild(svg.firstChild);
}
}
}
div.innerHTML = E;
return new Fragment(f);