Skip to content

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

Merged
DAreRodz merged 4 commits into
trunkfrom
fix/iapi-tovdom-revert-regex-capture-groups
May 16, 2024
Merged

DAreRodz merged 4 commits into
trunkfrom
fix/iapi-tovdom-revert-regex-capture-groups

Conversation

@DAreRodz

Copy link
Copy Markdown
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.

@github-actions

github-actions Bot commented May 16, 2024 •

Copy link
Copy Markdown

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. [Package] Interactivity /packages/interactivity labels May 16, 2024
@DAreRodz

Copy link
Copy Markdown
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

@sirreal sirreal left a comment

Copy link
Copy Markdown
Member

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 thread packages/interactivity/src/vdom.ts Outdated
Comment on lines +99 to +100
const namespaceAndPath =
nsPathRegExp.exec( attributeValue );

Copy link
Copy Markdown
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
Copy Markdown
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

sirreal commented May 16, 2024

Copy link
Copy Markdown
Member

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
@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. [Package] 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