lwc
lwc copied to clipboard
refactor(template-compiler): change invalid template attributes from warning to error
Details
This PR increases the strictness of the template compiler syntax by throwing an error instead of a warning when invalid template attributes are detected.
There are two scenarios that are affected by this change:
- The template only contains invalid template attributes
- The template contains a mix of valid and invalid attributes.
Scenario 1 example:
<template class="hello">
<p>hi</p>
</template>
Will now throw an error and will not render the contents of the template.
Scenario 2 example:
<template if:true={showItems} for:each={items} for:item="item" onfoo={handleFoo}>
<p key={item.id}>1{item}</p>
</template>
In the second scenario, the current behavior is for the template to ignore the invalid attributes (onfoo
) but continue to render the rest of the child elements and apply the valid attributes (if:true
, for:each
, and for:item
).
After this change, the new behavior will throw an error and not emit the child elements.
Does this pull request introduce a breaking change?
- 🚨 Yes, it does introduce a breaking change.
- Adding a new restriction to the compiler which might result in a compilation failure for existing code. See above for description of changes.
Does this pull request introduce an observable change?
- ⚠️ Yes, it does include an observable change.
- Adding a new restriction to the compiler which might result in a compilation failure for existing code. See above for description of changes.
GUS work item
W-11296404