fix: Regression itemscope
as boolean_attribute
#8414
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Microdata
Microdata are a strange set of attributes which are ONLY defined in markup, and have no relationship to the underlying Document Object Model node. As such programmatically defining an element and setting a property on it with a given Microdata attribute will not work:
https://codepen.io/iambrosius/full/jOvXBBG
One can read more about microdata here: https://developer.mozilla.org/en-US/docs/Web/HTML/Microdata
The Problem
When an attribute is declared in the set of
boolean_attributes
:svelte/src/shared/boolean_attributes.ts
Line 1 in aa4d0fc
And here:
svelte/src/compiler/compile/render_dom/wrappers/Element/Attribute.ts
Line 340 in aa4d0fc
The generated code looks like this:
The output above will not work as expected because, again, Microdata has no relationship to the underlying document node (it is strictly defined in markup).
This PR rewrites the
itemscope
test to be more accurate of whatitemscope
is intended to be, along with removing the declaration ofitemscope
as a boolean attribute in the respective files above.In addition it adds a test for the
hidden
attribute which is an attribute actually tied to the equivalent dom node property.I hope this helps prevent future regressions from happening
Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.Tests
npm test
and lint the project withnpm run lint