elementor/scripts
Netanel Baba 72f4cd5950
Fix: Version replacement in create-version-change script (#35076)
## Summary
- Fixed `$n` backreference misinterpretation in
`String.prototype.replace` — when the replacement was a string like
`$14.1.0`, JavaScript could ambiguously parse `$14` as a reference to
capture group 14 (which doesn't exist) instead of group 1 followed by
the literal `4`
- Changed `updateVersionInFile` to pass replacement as a proper function
via `(...args) => pattern.replacement(version, ...args)` so capture
groups are passed as named arguments
- Updated pattern `replacement` functions to use template literal
interpolation with named params (`prefix`, `suffix`) instead of `$n`
syntax

## Test plan
- [ ] Run `node scripts/create-version-change.js <version>
--skip-branches --dry-run` and verify no errors
- [ ] Run with a real version and confirm `elementor.php` `* Version:`
comment and `ELEMENTOR_VERSION` define are both updated correctly
<!--start_gitstream_placeholder-->
###  PR Description
Purpose: Fix version replacement logic in create-version-change script
to correctly handle regex capture groups and prevent incorrect string
substitutions.

Main changes:
- Updated replacement function to accept full regex match arguments
instead of just version parameter
- Modified replacement callbacks to use explicit capture group
parameters (prefix, suffix) instead of ###  PR Description
Purpose: Fix version replacement logic in create-version-change script
to correctly handle regex capture groups and prevent backreference
errors in string replacements.

Main changes:
- Modified updateVersionInFile to pass all regex match arguments to
replacement function using spread operator
- Updated elementor.php version patterns to use explicit capture group
parameters instead of numbered backreferences
- Fixed replacement functions to reconstruct strings using captured
prefix/suffix groups rather than $1/$3 placeholders

_Generated by LinearB AI and added by gitStream._
<sub>AI-generated content may contain inaccuracies. Please verify before
using.
💡 **Tip:** You can customize your AI Description using **Guidelines**
[Learn
how](https://docs.gitstream.cm/automation-actions/#describe-changes)</sub>/$3
backreferences
- Fixed regex replacement pattern to properly reconstruct matched
strings with correct capture group ordering

_Generated by LinearB AI and added by gitStream._
<sub>AI-generated content may contain inaccuracies. Please verify before
using.
💡 **Tip:** You can customize your AI Description using **Guidelines**
[Learn
how](https://docs.gitstream.cm/automation-actions/#describe-changes)</sub>
<!--end_gitstream_placeholder-->

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: ElementorBot <48412871+elementorbot@users.noreply.github.com>
2026-03-11 13:49:27 +02:00
..
create-version-change.js Fix: Version replacement in create-version-change script (#35076) 2026-03-11 13:49:27 +02:00
lint-packages-staged.js Internal: Add lint-stage to pre-commit hook [ED-20379] (#34473) 2026-01-28 15:47:57 +00:00
setup-test-environment.sh Internal: Convert to single turbo monorepo with unified workspace [ED-23202] (#35005) 2026-03-08 13:08:44 +02:00
setup-testing.sh Internal: Create a way for rendering elements inside an element with default settings [ED-20245] (#32407) 2025-08-25 14:54:38 +03:00