8
votes

I have a polymer element which has a costum element inside it. I want to remove everything (parent and child) when I click on it.

The problem is that every time I close an instance of the parent element I get an error. I think it's related to the fact I'm removing an element that has an element inside.

How can I remove it correctly?

Here's the method code:

closeWindow: function (event, detail, sender) {
    this.firstChild.remove();
    this.remove();
}

Here's the error I'm having:

Uncaught TypeError: Cannot read property 'length' of undefined

Here's an image of the error:

An image of the error

2
Can you create a jsfiddle that shows off this behavior?Peter Burns
What's wrong with just this.remove()?ebidel
Good news!! with the new release (0.2.4) this error seems to be solvediroyo
Interesting, I have a same problem. It doesn't seem to me that it has been resolved.Aero Wang

2 Answers

7
votes

This issue was fixed a few releases ago and should also work fine in Polymer 0.3.x onwards. If you run into any further issues with this.remove() within the scope of an element, please file an issue.

0
votes

On polymer 1.5.0+ you do event.target.remove()