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

Invalid fragment childNodes #2334

Closed
eeid26 opened this issue Aug 21, 2015 · 2 comments
Closed

Invalid fragment childNodes #2334

eeid26 opened this issue Aug 21, 2015 · 2 comments
Assignees
Labels

Comments

@eeid26
Copy link

eeid26 commented Aug 21, 2015

https://jsbin.com/yejizipile/edit?html,console,output
different path from #2311

for what it's worth, my temp fix is to always check in _updateChildNodes/shady.html if the real parentNode is the container. See code below.

_updateChildNodes: function(container, children) {
        var composed = getComposedChildren(container);
        var splices =
          Polymer.ArraySplice.calculateSplices(children, composed);
        // process removals
        for (var i=0, d=0, s; (i<splices.length) && (s=splices[i]); i++) {
          for (var j=0, n; (j < s.removed.length) && (n=s.removed[j]); j++) {
            if (container === n.parentNode) {
                remove(n);
            }
            composed.splice(s.index + d, 1);
          }
          d -= s.addedCount;
        }
        // process adds
        for (var i=0, s, next; (i<splices.length) && (s=splices[i]); i++) {
          next = composed[s.index];
          for (var j=s.index, n; j < s.index + s.addedCount; j++) {
            n = children[j];
            insertBefore(container, n, next);
            composed.splice(j, 0, n);
          }
        }
      },
@sorvell sorvell self-assigned this Aug 21, 2015
@sorvell sorvell added the p1 label Aug 21, 2015
@sorvell
Copy link
Contributor

sorvell commented Aug 21, 2015

Thanks for your patience and help tracking down these issues.

Yes, it looks like the issue is that removing the span from my-element and putting it into the fragment puts it in the fragment and then prompts my-element to distribute. When that happens, my-element assumes the span is still its responsibility and removes it. Your suggestion probably makes sense, thanks.

@eeid26
Copy link
Author

eeid26 commented Aug 21, 2015

I really appreciate the work you are doing. I know how difficult the code you are dealing with. Please keep the great work you are doing.

frankiefu added a commit that referenced this issue Aug 27, 2015
Fixes #2334: when composing nodes in shady dom, check if a node is wh…
MartinMoizard pushed a commit to MartinMoizard/polymer that referenced this issue Sep 8, 2015
…e is where we expect it to be before removing it from its distributed position. We do this because the node may have been moved by Polymer.dom in a way that triggered distribution of its previous location. The node is already where it needs to be so removing it from its parent when it's no longer distributed is destructive.
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

2 participants