Reputation: 175
Getting this error message when try to add a child element :
Uncaught TypeError: Failed to execute 'appendChild' on 'Node': parameter 1 is not of type 'Node'.
Upvotes: 0
Views: 2321
Reputation: 1283
In the context of your component, for example in the ready method, try the following.
ready(){
super.ready();
this.root.appendChild(newEle);
}
Or from outside of the component, for example in whatever hosts your component, try the following.
document.querySelector("your-component-is").root.appendChild(newEle);
Upvotes: 2
Reputation: 2531
You can try that :
// Get element from shadow dom
var containerEle = Polymer.dom(this.root).querySelector('shadow_dom_selector');
// Create dynamic element
var newEle = document.createElement('span');
newEle.textContent = 'Hello World';
// Append
containerEle.appendChild(newEle);
If your container element have an id
Polymer.dom(this.$.containerElementId).appendChild(newEle);
Upvotes: 2