Re: [dart-web] Polymer: Observe mutations on distributed nodes of ContentElement

106 views
Skip to first unread message

Justin Fagnani

unread,
Apr 20, 2014, 1:17:57 PM4/20/14
to w...@dartlang.org, polym...@googlegroups.com

+polymer-dev

Is there a way to observe mutations on distributed nodes of ContentElement using MutationObserver? Observing on childList doesn't seem to fire when distributed nodes are added or removed to ContentElement. I am forced to observe on root PolymerElement for now.

Thanks!

--
You received this message because you are subscribed to the Google Groups "Dart Web Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web+uns...@dartlang.org.
Visit this group at http://groups.google.com/a/dartlang.org/group/web/.
To view this discussion on the web visit https://groups.google.com/a/dartlang.org/d/msgid/web/15960217-310d-4eb0-a1f7-ba31553b91cf%40dartlang.org.

Scott Miles

unread,
Apr 20, 2014, 1:31:29 PM4/20/14
to Justin Fagnani, w...@dartlang.org, polymer-dev
We've been lobbying for such changes to be observable as Mutations (or at least as an event) for some time now. 

Will add your votes to the lobby effort!


Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/CAEKsHmAFApXNHqQ3BBDEHZUGAY3MdoXv003bSHuugog8Dn-4nw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Elliott Sprehn

unread,
Apr 20, 2014, 2:14:56 PM4/20/14
to Scott Miles, Justin Fagnani, w...@dartlang.org, polymer-dev
The biggest issue with this is that we don't distribute nodes until we recalculate style which is at requestAnimationFrame time, but after all your callbacks have run. So your MutationObserver would always miss one frame.



Scott Miles

unread,
Apr 20, 2014, 2:26:02 PM4/20/14
to Elliott Sprehn, Justin Fagnani, w...@dartlang.org, polymer-dev
Key info, thanks for that insight Elliott.


Jan Miksovsky

unread,
Apr 22, 2014, 2:20:01 PM4/22/14
to polym...@googlegroups.com, Elliott Sprehn, Justin Fagnani, w...@dartlang.org
+1 vote for some way to observe these mutations.

If I understand Justin's description, he's observing distribution changes by observing the light DOM node's children. I've been doing that for a while, but I've also been faced with numerous cases where I want to observe *re*distributed content, and don't see an obvious way to do that. That is, I have an element that wants to watch itself for distribution changes. Then that element itself is instantiated somewhere by some outer element, which puts a <content> node inside of the inner element instance. Now changes made to the outer element's children effect what's distributed to the inner element, but as far as the inner element is concerned, it's own children aren't changing (it just see that it contains a <content> node).

Without native support for this, it seems an element that wanted to handle redistributed nodes would need to not only monitor its own content, but would also need to look to see if its own content includes <content> elements, try to figure out the parent elements that added the <content>, then observe the *parent* for mutations as well... which all seems to quickly get ugly.

Are there any better solutions to this today? Or, if it needs to be done the hard way, has anyone already taken a shot at this?
Reply all
Reply to author
Forward
0 new messages