Skip to content

Loading…

DOM API innerHTML adds only first element #1972

Closed
SmokyBob opened this Issue · 2 comments

4 participants

@SmokyBob

JSbin + workaround

When trying to set a inner HTML only the first element is added to the node.
Polymer.dom(node).innerHTML = "<div>added</div><div>missing</div>"

A work around is to wrap the new html inside a div (see JS bin)

I think the culprit is this that uses e.nextSibling.

I think the for should loop over d.children or I miss something (ex. performance reason, etc...)?

@imskull

I had similar problem, I solved it by adding Polymer.dom.flush() in the loop, may that works for you as well.

@kevinpschaaf
              for (var e=d.firstChild; e; e=e.nextSibling) {
                this.appendChild(e);
              }

@sorvell In the case that the container does not require distribution, composition is fast-pathed and e is inserted into the composed DOM, rendering e.nextSibling null. Should probably capture an array copy of children and iterate that as @SmokyBob suggested.

@kevinpschaaf kevinpschaaf added the p1 label
@sorvell sorvell closed this in c943bd2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.