I agree and I think this is a general problem that the ShadowDOM spec
should address. I've tried to summarize the issue in this spec bug, to
which I linked this post.

https://www.w3.org/Bugs/Public/show_bug.cgi?id=24861

Feel free to contribute.


On Fri, Feb 28, 2014 at 7:03 AM, Erik Arvidsson <[email protected]> wrote:

> If I understand things correctly, the children of the inner-element never
> changes. Composition does not cause any DOM mutations.
>
>
> On Thu, Feb 27, 2014 at 7:28 PM, Sergey Shevchenko <[email protected]>wrote:
>
>> Hi all,
>>
>> The context for this is Polymer Dart, but @jmesserly thinks this is
>> probably a generic Shadow DOM + Mutation Observers question, so I'm asking
>> here.
>>
>> I'm trying to observe mutations in the distributed content of a <content>
>> tag as follows:
>>
>> @CustomTag(inner-element')
>> class MyElement {
>>   void enteredView() {
>>     new MutationObserver((m, o) => print("content changed")).observe(this
>> , childList: true);
>>   }
>> };
>>
>> That works when I use it like this:
>>
>> <inner-element>
>>   <template repeat="{{x in xs}}">
>>     {{x}}
>>   </>
>> </>
>>
>> But it breaks when there is another element that wraps around and
>> reprojects its distributed content into <inner-element>:
>>
>> <polymer-element name="outer-element">
>>   <template>
>>     <inner-element>
>>       <content></content>
>>     </inner-element>
>>   </>
>> </>
>>
>> <outer-element>
>>   <template repeat="{{x in xs}}">
>>     {{x}}
>>   </>
>> </>
>>
>> InnerElement does not see the changes in the xs. What it is the right way
>> to observe them? Ideally, I'd like it to be generic, i.e. working for both
>> cases above. As a less preferred option, I could implement a special case
>> for when the distributed content is a reprojected <content> from the
>> embedder.
>>
>> I could of course add a second MutationObserver to OuterElement and 
>> explicitly
>> tell InnerElement to update whenever a mutation happens, but it seems to me
>> that this defies the whole idea of MutationObservers.
>>
>> Thanks,
>> --Sergey
>>
>> 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 [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/polymer-dev/0994645a-acef-4867-a4d9-5379e21ae2bc%40googlegroups.com<https://groups.google.com/d/msgid/polymer-dev/0994645a-acef-4867-a4d9-5379e21ae2bc%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>
>
> --
> erik
>
>
>  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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/polymer-dev/CAJ8%2BGog30fZ7MfKJLLjnoWTxjz8P4N9XoZWdi62ADOh8AmdjrA%40mail.gmail.com
> .
>
> For more options, visit https://groups.google.com/groups/opt_out.
>

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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/polymer-dev/CA%2BrMWZgg6US-GkmeyxjZchP54La2UoMS%3D2TJR9Zxikc7dDSrvA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to