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

[1.0] shady dom inserts '<content>' more than once #1704

Closed
imskull opened this issue Jun 1, 2015 · 2 comments
Closed

[1.0] shady dom inserts '<content>' more than once #1704

imskull opened this issue Jun 1, 2015 · 2 comments

Comments

@imskull
Copy link

imskull commented Jun 1, 2015

My element:

<dom-module my-elem >
  <template>
    <div class="abc">
      <content></content>
   </div>
  </template>
  ...
</dom-module>

Scripts:

var html = "<my-elem>hello world</my-elem>";
var el1 = document.createElement("div");
el1.innerHTML = html;
var el2 = document.createElement("div");
el2.innerHTML = el1.innerHTML;

After, el2:

<my-elem>
  <div class="abc">
    <div class="abc">
    hello world
    </div>
  </div>
</my-elem>

Shady DOM should check if el2 is post-processed when trying to insert client content at insert point.

@imskull
Copy link
Author

imskull commented Jun 1, 2015

You may interesting why I convert HTML and element back and forth, basically, it is because localization and extracting templates from bulk of HTML, it's another story.

@sorvell
Copy link
Contributor

sorvell commented Jun 2, 2015

You'll running up against one of the limitations of the Shady DOM shim here. For reasons of practicality and performance, Shady DOM does not attempt to modify dom accessors to behave like Shadow DOM.

Instead the Polymer.dom api is provided to produce normalized output. In this case, e1.innerHTML is giving you the fully composed dom and you likely want scoped/local dom. Instead you should use Polymer.dom(e1).innerHTML. Here's a jsbin sample:

http://jsbin.com/gareni/3/edit?html,output

@sorvell sorvell closed this as completed Jun 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants