Skip to content

Fix element not calling attach internals #130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

christophe-g
Copy link
Contributor

Fix #127

The regression test does not pass on webkit without the fix

@christophe-g christophe-g force-pushed the fix-element-not-calling-attach-internals branch 2 times, most recently from 906d195 to df3a298 Compare May 24, 2024 17:43
@calebdwilliams
Copy link
Owner

Let’s rebase this and I’ll get it reviewed/merged. Appreciate the contribution @christophe-g and the feedback in the PR @asyncLiz.

@christophe-g christophe-g force-pushed the fix-element-not-calling-attach-internals branch from 4441adb to 96428e8 Compare May 26, 2024 13:26
@christophe-g
Copy link
Contributor Author

@calebdwilliams - rebased against latest commit.

@@ -393,9 +393,6 @@ export function forceElementInternalsPolyfill(forceCustomStateSet = true) {
} else if (this.tagName.indexOf('-') === -1) {
throw new Error(`Failed to execute 'attachInternals' on 'HTMLElement': Unable to attach ElementInternals to non-custom elements.`);
}
if (internalsMap.has(this)) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is the right fix. This is removing a guard against attaching a second internals instance. I think a better fix would be to not call upgrade internals if an instance it doesn't exist.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this, and removing the line didn't work, as the fix for upgradeInternals is needed to run for tests to pass with Stencil components with Jest, so in my take on it in #142 I added a flag to make to not throw the error if attachInternals is run in the upgradeInternals function

@Cliffback
Copy link
Contributor

@christophe-g and @calebdwilliams is this PR considered stale?

We are also in need of this fix, and very much hope that this could get looked at!

If stale, then could I branch out and address the requested change to make a new PR?

@calebdwilliams
Copy link
Owner

Let’s get the fix rebased and I’ll get that merged/released.

@christophe-g
Copy link
Contributor Author

christophe-g commented Mar 25, 2025 via email

@yannhub
Copy link

yannhub commented Apr 9, 2025

Hello @christophe-g, do you plan to work on rebasing this PR soon?
I tried your branch and it correctly fix the errors we had with lazy load web-component generated with StencilJS.

Also I don't think the polyfill need to warn about 'ElementInternals missing from the element' as you added in your PR. If web-component didn't call attachInternals, it will not work even when browser implemented the API.

@Cliffback
Copy link
Contributor

Due to the inactivity here, and both me and @yannhub being in need of this fix, I forked the branch of the PR, and created a new PR (#142) hopefully to get this resolved soon.

It is rebased on main, so @christophe-g should still be author of the appropriate commits, but would be more than happy to close my PR (or change it to only have my changes) if the original PR gets merged.

But I really hope that this can get looked at, that would be very much appreciated @calebdwilliams

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

polyfill not robust for elements that do not call attachInternals (e.g. -buttons)
5 participants