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

[0.8] Nested insertion points lose elements after distributeContent #1480

Closed
Sleeckx opened this issue May 3, 2015 · 9 comments
Closed

[0.8] Nested insertion points lose elements after distributeContent #1480

Sleeckx opened this issue May 3, 2015 · 9 comments
Assignees

Comments

@Sleeckx
Copy link

Sleeckx commented May 3, 2015

In the following scenario, Polymer.dom(this).children returns the <content> element.
Is this intended? If so, is going through the _distributedNodes property the correct way to get the real children or is there another api call I should be using?

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

@sorvell
Copy link
Contributor

sorvell commented May 5, 2015

Yes, if I read the example correctly, this is intended behavior. Shady DOM and Shadow DOM share the same design. The distribution of nodes changes rendering but not dom structure. In this case the <content> element is a child of the <x-inner>. The children of <x-outer> get distributed such that they render in place of the insertion point where they get selected.

To see nodes distributed to an insertion point, Polymer.dom provides Polymer.dom(node).getDistributedNodes().

Fwiw, you can also see to which insertion point a given element has been distributed (generally this is not needed too much) using Polymer.dom(node).getDestinationInsertionPoints().

@Sleeckx
Copy link
Author

Sleeckx commented May 5, 2015

Thanks Steve, this was exactly what I was looking for. I somehow overlooked this from the primer.

@Sleeckx Sleeckx closed this as completed May 5, 2015
@Sleeckx
Copy link
Author

Sleeckx commented May 5, 2015

The reason I bumped on the above question is for the following scenario where somehow the insertion point loses elements after distributeContent: http://jsbin.com/jejami/1/edit?html,output

Could this be related to this issue? #1394

@Sleeckx Sleeckx reopened this May 5, 2015
@Sleeckx Sleeckx changed the title [0.8] Polymer.dom(this).children and the <content> selector (feedback) [0.8] Nested insertion points lose elements after distributeContent May 5, 2015
@sorvell
Copy link
Contributor

sorvell commented May 5, 2015

Definitely looks like a bug or 2 here. I'll investigate. Thanks for the detailed test case.

@sorvell sorvell self-assigned this May 5, 2015
@Sleeckx
Copy link
Author

Sleeckx commented May 6, 2015

Thanks, I also updated the sample case to reflect the latest changes.

@sorvell
Copy link
Contributor

sorvell commented May 6, 2015

Currently, distributeContent is not smart enough to deal with redistribution. We'll fix it so it does.

In addition, we're planning on adding node mutation api (probably setAttribute and classList) to Polymer.dom so you should only rarely need to provoke distribution manually.

@sorvell
Copy link
Contributor

sorvell commented May 6, 2015

Actually, you are right that the precise problem you noted is related to #1394. What I said is also true... fixes for both are on the way.

@Sleeckx
Copy link
Author

Sleeckx commented May 7, 2015

Awesome, thanks!

Just to add some context to all of the above, this is the mock-up code of the real-world scenario we've build: http://jsbin.com/tireqatehe/1/edit?html

Adding the Polymer.dom API for adding/removing the attribute in this case and distributing immediately, will indeed eliminate the need to call distributeContent ourselves. Like you said.

@sorvell
Copy link
Contributor

sorvell commented May 12, 2015

Fixed via d5070c5

@sorvell sorvell closed this as completed May 12, 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