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

Interactivity API: Turn named capturing groups back into numbered ones inside toVdom #61728

Merged
merged 4 commits into from
May 16, 2024

Conversation

DAreRodz
Copy link
Contributor

What?

Reverts a recent change in dbf231a that introduced named capturing groups in the RegExp used to parse directive values.

const regexResult = nsPathRegExp.exec(
attributes[ i ].value
)?.groups;
const namespace = regexResult?.nameSpace ?? null;
let value: any =
regexResult?.value ?? attributes[ i ].value;

Why?

According to caniuse.com, named capturing groups have global support of 95.62%. Although the value is quite high, there could be users for whom the Interactivity API does not work just by using this feature.

For instance, global support of Proxy objects is 97.28%.

How?

Using numbered capturing groups instead.

Copy link

github-actions bot commented May 16, 2024

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: DAreRodz <darerodz@git.wordpress.org>
Co-authored-by: sirreal <jonsurrell@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@DAreRodz DAreRodz added [Type] Bug An existing feature does not function as intended [Feature] Interactivity API API to add frontend interactivity to blocks. [Packages] Interactivity /packages/interactivity labels May 16, 2024
@DAreRodz
Copy link
Contributor Author

I've added the [Type] bug label, but I'm not sure if that's the correct one. Should it be [Type] Enhancement instead?

cc: @sirreal

Copy link
Member

@sirreal sirreal left a comment

Choose a reason for hiding this comment

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

I didn't test, but the changes look good.

Comment on lines 99 to 100
const namespaceAndPath =
nsPathRegExp.exec( attributeValue );
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I don't love this name, maybe regexResult?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 6456504.

@sirreal sirreal added the Backport to Gutenberg Minor Release Pull request that needs to be backported to a Gutenberg minor release label May 16, 2024
@sirreal
Copy link
Member

sirreal commented May 16, 2024

We can leave it bug, I've also added a Gutenberg backport label because it would be nice to get this out in a patch version if there is one.

@DAreRodz DAreRodz enabled auto-merge (squash) May 16, 2024 16:30
@DAreRodz DAreRodz merged commit 43cdf75 into trunk May 16, 2024
62 checks passed
@DAreRodz DAreRodz deleted the fix/iapi-tovdom-revert-regex-capture-groups branch May 16, 2024 17:16
@github-actions github-actions bot added this to the Gutenberg 18.5 milestone May 16, 2024
bph pushed a commit to bph/gutenberg that referenced this pull request May 27, 2024
…s inside `toVdom` (WordPress#61728)

* Back to numbered capturing groups

* Change attrValue to attributeValue

* Move `attributeValue` initialization

* Change `namespaceAndPath` to `regexResult`


Co-authored-by: DAreRodz <darerodz@git.wordpress.org>
Co-authored-by: sirreal <jonsurrell@git.wordpress.org>
@talldan talldan removed the Backport to Gutenberg Minor Release Pull request that needs to be backported to a Gutenberg minor release label Jul 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Interactivity API API to add frontend interactivity to blocks. [Packages] Interactivity /packages/interactivity [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants