SnapSVG: Remove mask from an element (unmask)

1.5k Views Asked by At

I have my JS code in which I use Snap SVG. At some point I use

element.attr({mask:maskelement});

In that snippet, element and maskelement are two elements inside my svg.

Now I want to remove the mask. What would be the correct code that achieves this?

2

There are 2 best solutions below

1
mjkaufer On

I found an answer here, although I feel it's not the best answer.

Basically, you set the mask's display property to none with the following code

maskelement.attr("display", "none");

Although the SVG looks like there's no more mask, it doesn't truly remove the mask. I think there's a better answer available.

0
vusiliyK On

I had a similar problem. For some reason,

element.attr('mask', null');

does not work, so to make it work, I had to do:

element.node.removeAttribute('mask');