custom-elements-everywhere
custom-elements-everywhere copied to clipboard
Add inherited properties test
This adds a test of setting inherited properties - properties that are defined by accessors on a super class of the element class. Libraries can fail this check if the use a heuristic to decide when to set properties and that heuristic is only checking for own properties of the direct prototype of the element instance.
In reviewing this it's important to check that the each new test is correct:
- The new library component is using the
<ce-with-inheritance>
element - The
<ce-with-inheritance>
defining module is imported - The test is using the new library component
- The expectations are correctly copied from the other property tests
Preview this PR: https://custom-elements-everywhere.com/preview/preview/preview/2263/
Thanks @augustjk !
With the imports fixed, I don't think this shows any interesting failures. I think the new ones are from camelCase properties, so I'm going to remove that check to isolate only inheritance.
I was thrown off with a report of a different bug near this Svelte code: https://github.com/sveltejs/svelte/blob/6f508a011bc8051ab9f82cafa97c5292a4453b92/packages/svelte/src/runtime/internal/dom.js#L437
That looks like it's only looking at own properties before making an attribute/property decision, but it turns out there's a switch before that on elements with a -
in the name that goes to an in-check: https://github.com/sveltejs/svelte/blob/6f508a011bc8051ab9f82cafa97c5292a4453b92/packages/svelte/src/runtime/internal/dom.js#L483
I still think this is a decent test to have, since it's conceivable a library could have faulty logic here. At worst it bumps most libraries scores a bit with another passing test.