Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Mask created in second Snap SVG is added to defs of first one #207

Closed
Fyrd opened this Issue Mar 6, 2014 · 3 comments

Comments

Projects
None yet
4 participants
Contributor

Fyrd commented Mar 6, 2014

This looks similar to #103 but the fix there doesn't solve this bug.

Codepen demo:
http://codepen.io/anon/pen/ztnwE

Running the demo alerts the amount of masks in each SVG element, which should be 1 each.

I'm experiencing the same erratic behaviour:
I have about 30 DOM elements with an SVG node each, looping through them to create unique masks for each of them and even though I create the paths in the same scope as I apply them to the objects masked, the nodes are only to be found under the the very first node.

Is there a way of referencing a node in the HTML document so I can create the mask nodes manually?

Thanks in advance.

mm-tom commented Apr 16, 2014

+1 also experiencing this same issue.

Have tried to workaround with regular JS but failed. Bugs like this are deal breakers, now considering switching to svg.js, as this bug is already pretty old and there's no guarantee of a fix anytime soon - are Adobe actually supporting snap.svg?

I noticed that removing the cache on line 2026 from the getSomeDefs function prevents this issue (but presumably adds more overhead for the processing):

function getSomeDefs(el) {
    var cache = Snap._.someDefs;
    // if (cache && contains(cache.ownerDocument.documentElement, cache)) {
    //     return cache;
    // }

mm-tom commented Apr 18, 2014

Amazing, thanks Dmitry!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment