webreflection
WebReflection Ltd
A polyfill for Custom Element built-in
Home Page: https://medium.com/@WebReflection/extending-built-in-elements-9dce404b75b4
License: ISC License
WebReflection Ltd
Before I get to the bug: love your open source work โค๏ธ
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 ๐
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).
Line 51 in d2e17e3
Edge (and IE 11) requires to set option attributes
to true
.
Please change to
{attributes: true, attributeFilter: oa, attributeOldValue: true}
to make Edge works.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.