Code Monkey home page Code Monkey logo

built-in-element's Introduction

webreflection

WebReflection Ltd

built-in-element's People

Contributors

webreflection avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

built-in-element's Issues

Mutation Observer: new elements that appear because of outerHTML aren't set up

Before I get to the bug: love your open source work โค๏ธ

The issue:

When a parent element is replaced using outerHTML only the parent element appears as a change in the Mutation Observer callback, not its children. So if the changed element now has new elements with the is attribute those elements aren't set up in the Mutation Observer callback and never get connected.

And similarly previously upgraded elements that are removed this way don't get disconnected properly.

The way I fixed the issue in the project I'm working on was by adding the following after the setupIfNeeded(addedNodes[j]) line in the Mutation Observer:

if (addedNodes[j].querySelectorAll) {
    addedNodes[j].querySelectorAll('[is]').forEach(node => {
          setupIfNeeded(node)
    })
}

And then something similar for disconnecting in the removedNodes block later.

Not proposing you fix it this way. I'm sure there are better ways of solving this problem. I only needed to get things working in a quick prototype I'm making ๐Ÿ™‚

Tested in

Safari. Most of the other browsers we're targeting either support built-ins or don't support custom elements at all (and so get the document-register-element polyfill instead).

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.