Fix clipPath coercion when used multiple times (#498)

Check parent nodes before coercing elements into clipPaths to prevent
the same element being coerced multiple times.

Fixes adobe-webplatform/Snap.svg#471
master
Thomas Brierley 2017-02-01 00:04:04 +00:00 committed by Dmitry Baranovskiy
parent 230396fd68
commit a63c1e6127
1 changed files with 14 additions and 3 deletions

View File

@ -64,9 +64,20 @@ Snap.plugin(function (Snap, Element, Paper, glob, Fragment) {
}(function (value) {
if (value instanceof Element || value instanceof Fragment) {
eve.stop();
if (value.type == "clipPath") {
var clip = value;
} else {
var clip,
node = value.node;
while (node) {
if (node.nodeName === "clipPath") {
clip = new Element(node);
break;
}
if (node.nodeName === "svg") {
clip = undefined;
break;
}
node = node.parentNode;
}
if (!clip) {
clip = make("clipPath", getSomeDefs(this));
clip.node.appendChild(value.node);
!clip.node.id && $(clip.node, {