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:
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With