Snap.svg
Snap.svg copied to clipboard
0.5.1 Tarball Inconsistency
Hello.
The current available tarball on npm https://registry.npmjs.org/snapsvg/-/snapsvg-0.5.1.tgz contains the following snippet of code
function Snap(w, h) {
if (w) {
if (w.nodeType) {
return wrap(w);
}
if (is(w, "array") && Snap.set) {
return Snap.set.apply(Snap, w);
}
if (w instanceof Element) {
return w;
}
if (h == null) {
// try {
w = glob.doc.querySelector(String(w));
return wrap(w);
// } catch (e) {
// return null;
// }
}
}
w = w == null ? "100%" : w;
h = h == null ? "100%" : h;
return new Paper(w, h);
}
Here the try-catch is outcommented.
This is not the issue in the master branch or at the tag 0.5.1.
This affects the Snap selector and hence all methods that make use of it, since for example Element.attr does not work on "stroke" returning a color like "rgb(0, 0, 0)", as deeper in the code the Snap selector would be used as Snap("rgb(0, 0, 0)") invoking an error.
I wouldn't use 0.5.1, use the dev branch 0.5.2.