partytown icon indicating copy to clipboard operation
partytown copied to clipboard

fix: make sure unknown is mapped to HTMLUnknownElement cstr

Open hoebbelsB opened this issue 1 year ago • 13 comments

What is it?

  • [ ] Feature / enhancement
  • [x] Bug
  • [ ] Docs / tests

Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

The issue

Chrome maps correctly

image

WebKit browsers map other nodeNames (in this case DIRECTORY) to HTMLUnknownElement

image

Which results in the hardcoded UNKNOWN property being undefined in WebKit browsers, causing them to throw errors like a madman.

image

image

The reason

Webkit iterates over the possible APIs in a different order. It will receive directory as first nodeName which results in HTMLUnknownElement constructor. The function readOwnImplementation maintains a Set<string> with constructor names. So the first one to occupy the space for HTMLUnknownElement will be directory.

If you filter for the possible cstrImpls which have the HTMLUnknownElement constructor name, you'll get multiple results with different orderings, depending on the browser.

Broken ordering on webkit

image

Proper ordering on chrome

image

The fix

I've simply introduced a new filter that filters out all nodenames that will result in HTMLUnknownElement, but UNKNOWN. The worker will anyway fall back to HTMLUnknownElement, so there should be no change in functionality.

Checklist:

  • [x] My code follows the developer guidelines of this project
  • [x] I have performed a self-review of my own code
  • [ ] I have made corresponding changes to the documentation
  • [ ] Added new tests to cover the fix / functionality

hoebbelsB avatar Jun 25 '24 10:06 hoebbelsB

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
partytown ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 25, 2024 10:58am

vercel[bot] avatar Jun 25 '24 10:06 vercel[bot]

no idea why the test would fail because of my changes. They also fail locally for me when checking out the main branch

hoebbelsB avatar Jun 25 '24 13:06 hoebbelsB

I see, thanks @hoebbelsB for your help

gioboa avatar Jul 01 '24 12:07 gioboa

Hello @gioboa

Is there anything we can do to move it forward?

aaa123eee avatar Aug 28 '24 10:08 aaa123eee

Hi @aaa123eee, I'm sorry. I'm no longer in the project. You can contact the builder.io team in this Discord channel Thanks

gioboa avatar Aug 28 '24 11:08 gioboa

Hi @aaa123eee, I'm sorry. I'm no longer in the project. You can contact the builder.io team in this Discord channel Thanks

Thanks for your reply and your contributions!

aaa123eee avatar Aug 28 '24 12:08 aaa123eee

Hi @aaa123eee, I'm sorry. I'm no longer in the project. You can contact the builder.io team on this Discord channel Thanks

Unfortunately this link does not work for me image

Is there anybody I can ask for a proper one? probably @adamdbradley @mhevery

aaa123eee avatar Aug 28 '24 13:08 aaa123eee

there's a related issue about that https://github.com/BuilderIO/partytown/issues/547

maybe @hamatoyogi knows 🤔

Unfortunately this link does not work for me image

Is there anybody I can ask for a proper one? probably @adamdbradley @mhevery

aaa123eee avatar Aug 28 '24 13:08 aaa123eee

@aaa123eee can you try this one please?

gioboa avatar Aug 28 '24 13:08 gioboa

@aaa123eee can you try this one please?

this invite works well! thank you!

aaa123eee avatar Aug 28 '24 14:08 aaa123eee

there's a related issue about that #547

maybe @hamatoyogi knows 🤔

Unfortunately this link does not work for me image Is there anybody I can ask for a proper one? probably @adamdbradley @mhevery

Hey, I'm no longer at Builder, but maybe if i tag @steve8708 something will happen 😅

hamatoyogi avatar Sep 04 '24 11:09 hamatoyogi

Thanks for the PR, we will have a look at this next week.

kylefowler avatar Sep 06 '24 18:09 kylefowler

I think if we can get a unit test on the change to verify behavior following our contribution guides we should be good to get this merged in. thanks for the patience here. https://github.com/BuilderIO/partytown/blob/main/CONTRIBUTING.md#submitting-issues-and-writing-tests

kylefowler avatar Sep 17 '24 18:09 kylefowler

yo, cool to see you back. will do as soon as I find time! Hopefully this week

hoebbelsB avatar Nov 18 '24 13:11 hoebbelsB

@hoebbelsB is this PR still valid?

gioboa avatar Dec 09 '24 14:12 gioboa

@hoebbelsB is this PR still valid?

it definitely is!

aaa123eee avatar Dec 11 '24 15:12 aaa123eee

@aaa123eee Do you also have this error? if yes, can you check this change to verify it please?

I've simply introduced a new filter that filters out all nodenames that will result in HTMLUnknownElement, but UNKNOWN.

@hoebbelsB based on your description I changed the filter logic. is it correct? remove the HTMLUnknownElement with UNKNOWN and keep the others

return (constructorName !== 'HTMLUnknownElement' || elm.nodeName.toUpperCase() !== 'UNKNOWN');

gioboa avatar Dec 11 '24 20:12 gioboa

@gioboa no, it's not the same as before.

I've also worked on a test to proof it. I've double checked the previous, my solution and your solution. With previous (main), test fails on webkit only. With your solution the test also fails on chromium & webkit. With my solution the test passes.

hoebbelsB avatar Dec 12 '24 14:12 hoebbelsB

@gioboa Is there any way that you can cut a new version that includes this fix?

stdavis avatar Dec 19 '24 14:12 stdavis

@gioboa Is there any way that you can cut a new version that includes this fix?

Yep, I'll create the first release for the QwikDev org

gioboa avatar Dec 19 '24 15:12 gioboa