Skip to content
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

fix(template-compiler): add deprecated void elements back #3037

Merged
merged 5 commits into from
Sep 10, 2022

Conversation

jmsjtu
Copy link
Member

@jmsjtu jmsjtu commented Sep 9, 2022

Details

#2898 removed <param>, <menuitem>, and <keygen> as valid void elements as per the HTML spec (see here for a list of deprecated elements). However, this introduced a regression in some customer sandboxes because of the usage of the deprecated <param> tag.

This PR addresses the regression by adding the deprecated void elements back into the list of void elements that are checked in the template compiler until the LWC team has decided to fully deprecate them.

One thing to note is that there were several elements removed from the list of void elements that are checked against in the list of void elements.

These elements included both SVG and HTML elements, however, after doing an analysis of the splunk logs for all sandboxes, we determined that there were no occurrences of the SVG elements being used incorrectly as HTML elements.

I have therefore left out the SVG elements as void elements to be checked against.

Does this pull request introduce a breaking change?

  • ✅ No, it does not introduce a breaking change.

Does this pull request introduce an observable change?

  • ⚠️ Yes, it does include an observable change.

There is an observable change, the components that used either <param>, <menuitem>, or <keygen> elements will not compile successfully.

GUS work item

W-11731809

yarn.lock Outdated Show resolved Hide resolved
export function isVoidElement(name: string, namespace: string): boolean {
return namespace === HTML_NAMESPACE && VOID_ELEMENTS_SET.has(name.toLowerCase());
return (
namespace === HTML_NAMESPACE &&
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably be faster keeping two arrays, creating one set out of it and doing the .has(name.toLowerCase()) once?

Copy link
Member Author

Choose a reason for hiding this comment

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

Great idea! Updated in the latest commit.

Copy link
Contributor

@jodarove jodarove left a comment

Choose a reason for hiding this comment

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

lgtm

"warnings": [
{
"code": 1057,
"message": "LWC1057: label is not valid attribute for menuitem. For more information refer to https://developer.mozilla.org/en-US/docs/Web/HTML/Element/menuitem",
Copy link
Contributor

Choose a reason for hiding this comment

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

🤔 ... label is supported in menuitem according to https://developer.mozilla.org/en-US/docs/Web/HTML/Element/menuitem"

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this is because the list of attributes we're comparing against doesn't account for menuitem attributes.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think it may be because these elements are technically deprecated?

"warnings": [
{
"code": 1057,
"message": "LWC1057: name is not valid attribute for keygen. For more information refer to https://developer.mozilla.org/en-US/docs/Web/HTML/Element/keygen",
Copy link
Contributor

Choose a reason for hiding this comment

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

this is supported by keygen

Copy link
Member Author

Choose a reason for hiding this comment

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

Same thing as the above except for keygen

@jmsjtu jmsjtu merged commit 4dd6713 into master Sep 10, 2022
@jmsjtu jmsjtu deleted the jtu/fix-deprecated-void-elements branch September 10, 2022 00:20
ravijayaramappa pushed a commit that referenced this pull request Sep 10, 2022
* build: replace lerna with nx (#2965)

* fix(template-compiler): add deprecated void elements back (#3037)

* chore: release v2.23.3 (#3039)
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.

None yet

3 participants