Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOM API innerHTML adds only first element #1972

Closed
SmokyBob opened this issue Jun 27, 2015 · 2 comments
Closed

DOM API innerHTML adds only first element #1972

SmokyBob opened this issue Jun 27, 2015 · 2 comments
Assignees
Labels

Comments

@SmokyBob
Copy link

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
Copy link

imskull commented Jun 27, 2015

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

@kevinpschaaf
Copy link
Member

              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.

@sorvell sorvell closed this as completed in c943bd2 Jul 8, 2015
kevinpschaaf added a commit that referenced this issue Jul 8, 2015
Fixes #1972: make setting innerHTML correctly traverse added dom.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants