Skip to content

Loading…

`getDistributedNodes()` returns nodes that are already removed under shady dom #2283

Closed
zerodevx opened this Issue · 0 comments

2 participants

@zerodevx

Hi, I'm not sure if this is expected behavior. Say I have an element <x-test> that selects and inserts content from its parent,

<x-test>

<dom-module id="x-test">
  <template>
    <div>x-test's distributed nodes:</div><br>
    <content id="content" select="[data-test]"></content>
  </template>
</dom-module>

and from my parent, I call it like that,

<parent-element>

<dom-module id="parent-element">
  <template>
  ...
    <x-test id="app">
      <template is="dom-repeat" items="{{list}}">
        <div data-test>{{item.foo}}</div>
      </template>
    </x-test>
  </template>
</dom-module>

where <parent-element>'s list array looks like

this.push("list", { foo: "item 1" });
this.push("list", { foo: "item 2" });
this.push("list", { foo: "item 3" });

everything works like a champ so far. Calling Polymer.dom(content).getDistributedNodes() returns the 3 items.

However, if I remove an item from the list,

this.splice("list", 2, 1);

while the template renders just fine, getDistributedNodes() still returns the full 3 items - when I expect 2 items. This works correctly under native shadow dom behaviour and I thought it should be normalised.

Here is a repro: http://jsbin.com/xebelufika/edit?html,output

Try adding some items, log the nodes, remove some, log the nodes, then add again. It seems that adding an item corrects this behavior.

Thanks so much,
Jason

@sorvell sorvell referenced this issue from a commit
@sorvell sorvell Fixes #2253: refine logical tree check and populate parents of insert…
…ion points with logical info only if necessary.

Fixes #2283: when a node is removed, we need to potentially distribute not only its host but also its parent.
6619f6c
@sorvell sorvell added the p1 label
@sorvell sorvell self-assigned this
@frankiefu frankiefu closed this in #2293
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.