Hi,
Here, you _should_ be using `Polymer.dom` when removing children. By omitting this, you're ignoring shady DOM when deleting children, so you'll delete both light DOM and shady DOM children at the same time. We may not know whether the radio group has any shadow children, but if it does, we _definitely_ don't want to mess with them. Just the light children.
Then in the last line, you add the new radio button to the shadow DOM instead of the light DOM.
var apRadioGroup = document.querySelector('#apRadioGroup');
// removing all previous children
while (child = Polymer.dom(apRadioGroup).firstChild) {
Polymer.dom(apRadioGroup).removeChild(child);
}
this.results.forEach(function(res) {
// create and add a new element
var rb = document.createElement('paper-radio-button');
Polymer.dom(rb).setAttribute('name',res.ssid);
Polymer.dom(rb).innerHTML += res.ssid;
Polymer.dom(rb).innerHTML += ' [' + res.dBm + 'dBm]';
Polymer.dom(apRadioGroup).appendChild(rb);
});
In other words:
- Use Polymer.dom consistently when adding _and_ removing children.
- In most cases, a component should only manipulate its own shadow DOM. If you're doing Polymer.dom(component.root) from outside component, that might be a red flag.
Here's a jsbin with a (slightly simplified) version of the above:
Hope that helps.
Arthur