-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Interactivity API: Allow "default" suffix values #65815
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Size Change: -28 B (0%) Total Size: 1.77 MB
ℹ️ View Unchanged
|
I'm investigating test failure now. |
isDefaultDirectiveSuffix, | ||
isNonDefaultDirectiveSuffix, |
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.
What's the reasoning behind having two utils for the same check?
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.
They're both type guards so Array.prototype.filter
and Array.prototype.find
work with them to narrow types. Type guards are one-sided, however, the true
case is narrowed, so because we narrow to the default suffix and to a non-default suffix, it's necessary to have both.
This could be done other ways, but this seemed expressive and clear. I'd also originally implemented this with a symbol
as the default value, but that wasn't necessary and switching the implementation was simple.
…fault-suffix-collision
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.
Great PR!
The e2e test makes it easy to verify the behavior. Thanks for adding richer TS types and adding clearer names in the e2e tests too! 👍
Should this have the |
I'd like to know what folks think. If everyone is confident and happy with this change than it may be good to backport. |
I'll go ahead and land this. I don't believe it's critical for a backport but if folks would like to backport it that would also be fine. |
Thanks @sirreal, this change makes a lot of sense. It is easier to understand that entries where Regarding whether this PR should be backported, I would be in favor. 🙂 |
I've added the label, I'm not sure whether automation will pick up this PR automatically now. |
Fix an issue where "default" could not be used as "suffix" values in Interactivity API directives, for example in a directive like: data-wp-class--default="…" --- Co-authored-by: sirreal <jonsurrell@git.wordpress.org> Co-authored-by: michalczaplinski <czapla@git.wordpress.org> Co-authored-by: gziolo <gziolo@git.wordpress.org>
I just cherry-picked this PR to the wp/6.7 branch to get it included in the next release: 3ee7c74 |
Fix an issue where "default" could not be used as "suffix" values in Interactivity API directives, for example in a directive like: data-wp-class--default="…" --- Co-authored-by: sirreal <jonsurrell@git.wordpress.org> Co-authored-by: michalczaplinski <czapla@git.wordpress.org> Co-authored-by: gziolo <gziolo@git.wordpress.org>
What?
Fix an issue where "default" could not be used as "suffix" values in Interactivity API directives:
I noticed this while investigating https://core.trac.wordpress.org/ticket/62131 / #65803.
Why?
"default" should be a valid value. This is most notable in the class directive where
default
is a valid class name but the client ignores it.How?
Internally, the string value "default" was used to indicate the default suffix. Instead of a string value, a different value type,
null
in this case, can be used to indicate the default suffix.Testing Instructions
The PR includes e2e tests for the behavior.
Manual testing would be similar to the e2e test:
Screenshot
Trunk
trunk.mov
Branch
branch.mov