Giter VIP home page Giter VIP logo

Comments (7)

WebReflection avatar WebReflection commented on September 25, 2024 1

You need childList too

from uhtml.

WebReflection avatar WebReflection commented on September 25, 2024

uhtml knows nothing about ShadowDOM, so it'll keep updating the element content, not its shadow-root, which is expected (or better, it's by design, no ShadowDOM checks whatsoever as ShadowDOM has mode closed that would make it fail anyway).

However, if you instrument your observe to move within its shadowRoot nodes, everything should be fine:

      new MutationObserver((mutations) => {
        for (const {addedNodes} of mutations) {
          for (const node of addedNodes)
            this.shadowRoot.appendChild(node);
        }
      })

closing, as this is not something uhtml should solve, as it does exactly what it's expected to to 👋

from uhtml.

lemmon avatar lemmon commented on September 25, 2024

Nope. I understand that uhtml doesn't access Shadow DOM, that's not my intention. As per my example:

html`
  <custom-element>${someValue}</custom-element>
`

...I am looking for changes of the someValue inside the <custom-element> tag. That element has Shadow DOM attached but changes happen within the main template whis uhtml has access to.

from uhtml.

WebReflection avatar WebReflection commented on September 25, 2024

I think my example code works as expected already, right?

from uhtml.

lemmon avatar lemmon commented on September 25, 2024

Maybe my explanation is confusing. I am not seeing the MO gets triggered on re-render.

a

...after re-rendering the template serveral times I am seeing in the inspector that inner content of the element has changed, but...

Screenshot 2020-12-03 at 18 49 53

...the observer has been triggered only on first render. No other render triggers the thing. Only accessing the element via textContent or appendChild triggers the event.

from uhtml.

lemmon avatar lemmon commented on September 25, 2024

When observing attributes I am getting the result I am expecting. But not with the inner content changes.

from uhtml.

lemmon avatar lemmon commented on September 25, 2024

Okay, I guess I have figured it out. I need to pass combination of options:

{
  characterData: true,
  subtree: true,
}

Thank you!

from uhtml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.