-
Notifications
You must be signed in to change notification settings - Fork 632
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
feat(html/unstable): add isValidCustomElementName()
#5456
feat(html/unstable): add isValidCustomElementName()
#5456
Conversation
I was wondering about the name staring with |
@timreichen hmmmm, I'm more inclined to do |
|
I would put |
The latter seems better for me, more descriptive. I'll put that in right now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Just a few nits.
I'd prefer the name
The function name starting with |
The function name starting with |
isValidCustomElement()
isValidCustomElement()
isValidCustomElement()
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5456 +/- ##
==========================================
- Coverage 96.37% 96.00% -0.37%
==========================================
Files 465 466 +1
Lines 37506 37526 +20
Branches 5527 5497 -30
==========================================
- Hits 36147 36028 -119
- Misses 1317 1456 +139
Partials 42 42 ☔ View full report in Codecov by Sentry. |
isValidCustomElement()
isValidCustomElementName()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made changes to align with the codebase. Now, LGTM. Thanks!
isValidCustomElementName()
isValidCustomElementName()
Sorry to take long to answer guys! |
}); | ||
|
||
await t.step("handles custom names with underscores", () => { | ||
assertEquals(isValidCustomElementName("custom_element"), true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A custom element name needs to include at least one -
. This shouldn't be a valid name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmmm, you're right, just took a look at the HTML reference and got it. I'll fix it tomorrow afternoon
}); | ||
|
||
await t.step("handles custom names with points", () => { | ||
assertEquals(isValidCustomElementName("custom.element"), true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto. This isn't a valid name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've fixed the previously mentioned faults and improved tests. LGTM now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also cleaned up the regexp a bit.
LGTM
These changes add a isValidCustomElement method to validate a custom element created in the HTML document. It is implemented according to the HTML spec that can be found at: https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
I have also added tests for all the cases I could think of, if any case is missing please let me know and I can add it.
Closes #5437