8000 Proposal to Validate the "name" of parentElement in createIsolatedElement · Issue #59 · aklinker1/webext-core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Proposal to Validate the "name" of parentElement in createIsolatedElement #59

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

Closed
1natsu172 opened this issue Apr 16, 2024 · 3 comments · Fixed by wxt-dev/wxt#625
Closed

Comments

@1natsu172
Copy link
Contributor

Hello,

I am now using your excellent project (WXT) to replace my 7-year maintained chrome extension to Web Extension.

Main Issue

What do you think about strictly validating the name of the parentElement in the createIsolatedElement function that calls attachShadow?

My background

I wasn't aware of the rule that names must be in kebab-case, and it cost me half a day. (The browser logs didn't help, and I was at a loss.)

console error of browser(Chromium)

The content script "content" crashed on startup! DOMException: Failed to execute 'attachShadow' on 'Element': This element does not support attachShadow

After carefully comparing my project with the example template, reading the attachShadow reference, and checking the WHATWG spec sheet, I finally found a hint about the constraints of PotentialCustomElementName.

It was only after I understood the issue that I noticed the kebab-case comment in JSDoc! (because it wasn’t a type error)

Therefore...

According to the spec sheet that PotentialCustomElementName includes more complex constraints than just kebab-case. I found a validation library that seems usable:

is-potential-custom-element-name

I considered preventing this with TypeScript types, but representing complex validations seems challenging.

I believe that appropriate validation error messages in the error logs would save a lot of time in the future.


Sorry for the long post!

@aklinker1
Copy link
Owner

Oof, yeah, sorry that took you so long to figure out. Seems like a good library, thanks for the suggestion. I can add it, unless you'd like to contribute it?

@1natsu172
Copy link
Contributor Author

Thanks for the quick reply. Since it’s not urgent, I’ll submit a Pull-request. I’ll see you later!

@aklinker1
Copy link
Owner

Released in WXT v0.18.0

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 a pull request may close this issue.

2 participants
0