Skip to content

[ShadyDOM] Mutation Observer callback is not called for shadow hosts #81

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

Open
3 of 4 tasks
tomalec opened this issue Jul 3, 2018 · 4 comments
Open
3 of 4 tasks

Comments

@tomalec
Copy link
Contributor

tomalec commented Jul 3, 2018

Description

Mutation Observer callback is not called when elements are added or removed from shadow host.

<div id="shadowHost"></div>
<script>
  shadowHost.attachShadow({mode:'open'}).innerHTML = `<div><slot></slot></div>`;
  var hostObserverCalled = false;
  (new MutationObserver((mutationsList)=>{
    console.info('mutated');
    hostObserverCalled = true;      
  })).observe(shadowHost, { childList: true });
  
  shadowHost.appendChild(document.createElement('div'));
  
  setTimeout(()=>{
    console.assert(hostObserverCalled, 'Shadow hot\s mutation observer callback should be eventually called.');
  }, 500);
</script>

Live Demo

https://glitch.com/edit/#!/mutationobserver-on-shadowhost?path=index.html:15:41

Steps to Reproduce

  1. Attach shadow root to an element.
  2. Attach mutation observer {childList: true} and observe the element.
  3. Create div.
  4. Append div to the element or remove existing element.

Expected Results

Mutation observer callback should get called

Actual Results

The callback is not called

Browsers Affected

  • Chrome
  • Firefox
  • Edge
  • [?] Safari 9
  • [?] Safari 8
  • IE 11

Versions

  • webcomponents: v2.0.2
@tomalec tomalec changed the title Muttion Observer callback is not called for shadow hosts Mutation Observer callback is not called for shadow hosts Jul 3, 2018
@dfreedm dfreedm transferred this issue from webcomponents/shadydom Jun 7, 2019
@dfreedm dfreedm changed the title Mutation Observer callback is not called for shadow hosts [ShadyDOM] Mutation Observer callback is not called for shadow hosts Jun 12, 2019
dfreedm added a commit that referenced this issue Jun 12, 2019
@wbern
Copy link

wbern commented Apr 21, 2020

Has anyone recognized this issue? Ran into it today.

@calebdwilliams
Copy link
Contributor

Having the same issue

@stale
Copy link

stale bot commented Jun 17, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Jun 17, 2021
@stale
Copy link

stale bot commented Sep 17, 2023

This issue has been automatically closed after being marked stale. If you're still facing this problem with the above solution, please comment and we'll reopen!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants