Skip to content

fix(rsc): reset stateful directive regexes#1256

Open
james-elicx wants to merge 2 commits into
vitejs:mainfrom
james-elicx:codex/rsc-stateful-directive-regex
Open

fix(rsc): reset stateful directive regexes#1256
james-elicx wants to merge 2 commits into
vitejs:mainfrom
james-elicx:codex/rsc-stateful-directive-regex

Conversation

@james-elicx

Copy link
Copy Markdown
Contributor

Extracted from #1246.

Global and sticky directive regexes retain lastIndex, so later functions or repeated transforms can miss matching directives.

This resets regex state around each match. Tests cover both g and y regexes, multiple functions, repeated transforms, and the final lastIndex.

@james-elicx
james-elicx marked this pull request as ready for review June 30, 2026 23:29

@hi-ogawa hi-ogawa left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do you have a use case for y? The g case works without resetting.

The fix seems correct and don't mind including it but I'm not sure if when lib provides regex config/option like this, it's always lib side responsibility to normalize in general.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants