Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Polymer: Correctly remove polymer element whith elements inside it

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

like image 387
iroyo Avatar asked May 17 '14 19:05

iroyo


People also ask

What is the correct polymer element lifecycle?

Polymer element lifecycle. Polymer elements follow the standard lifecycle for custom elements. The custom element spec provides a set of callbacks called "custom element reactions" that allow you to run user code in response to certain lifecycle changes.

What is a polymer element?

Polymer elements are a set of visual and non-visual elements designed to work with the layout, user interaction, selection, and scaffolding applications. These include everything from a simple button to a dialog box with neat visual effects.

Does Polymer help in creating custom elements?

Polymer adds a set of features to the basic custom element: Instance methods to handle common tasks. Automation for handling properties and attributes, such as setting a property based on the corresponding attribute. Creating shadow DOM trees for element instances based on a supplied template.


1 Answers

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.

like image 120
addyo Avatar answered Oct 26 '22 23:10

addyo