redefine-custom-elements icon indicating copy to clipboard operation
redefine-custom-elements copied to clipboard

Don't use the constructor call trick when a custom element is constructed with new

Open rictic opened this issue 3 years ago • 2 comments

We need to use the constructor call trick in the PivotCtor when the element has been created by the browser directly (e.g. document.createElement, or via the parser) because in that case the only constructor that's called is the PivotCtor.

However, if the element is called via new MyElement() then the MyElement constructor (and any superclass constructors) will be called properly without any work on our part.

This change fixes a bug we noticed where calling new MyElement() was running constructors twice.

rictic avatar Sep 15 '22 01:09 rictic

@rictic thanks for the PR, but it is impossible to review... can you update the PR with the actual changes? The diff, even when ignoring the whitespaces, it is the entire file.

caridy avatar Nov 30 '22 03:11 caridy

This builds on top of https://github.com/caridy/redefine-custom-elements/pull/3 to make it easier to merge them both, if you look at just the second commit the change is clearer

rictic avatar Nov 30 '22 20:11 rictic