-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Parser: Fix boolean attribute explicit string value result #7610
Conversation
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 dig it! A few comments/questions but approach is right on.
@@ -19,6 +19,22 @@ import { isValidBlock } from './validation'; | |||
import { getCommentDelimitedContent } from './serializer'; | |||
import { attr, prop, html, text, query, node, children } from './matchers'; | |||
|
|||
/** | |||
* Higher-order hpq matcher which enhances an attribute matcher to return 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.
Nice docs 👍
blocks/api/parser.js
Outdated
* | ||
* @param {Function} matcher Original hpq matcher. | ||
* | ||
* @return {Function} Enhanced hpq matcher.`` |
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.
Not sure what the backticks at the end are for 🤷♂️
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.
Not sure what the backticks at the end are for 🤷♂️
Fat fingered 😄
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.
That was my guess 😆
blocks/api/parser.js
Outdated
*/ | ||
export const toBooleanAttributeMatcher = ( matcher ) => flow( [ | ||
matcher, | ||
( value ) => value !== undefined, |
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 almost asked "what about a false
value?" but that should never happen. Not sure if it's worth adding docs just to remind the reader about that.
@@ -132,6 +174,19 @@ describe( 'block parser', () => { | |||
expect( value ).toBe( true ); | |||
} ); | |||
|
|||
it( 'should return the matcher\'s true boolean attribute value on explicit attribute value', () => { |
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.
This is definitely a case where I'm like #7366 for the win 😉
Nice, I love the table 👍 |
Thanks @aduth |
Related: #7322
This pull request seeks to fix an issue in the implementation of #7322 where an explicit string value assigned as an attribute would be wrongly interpreted as
false
when assigned as aboolean
attribute type. Both<input disabled>
and<input disabled="disabled">
should returntrue
for a boolean attribute source type.Testing instructions:
Ensure unit tests pass:
Repeat testing instructions from #7322.