File tree Expand file tree Collapse file tree 3 files changed +10
-1
lines changed
packages/core-js/internals Expand file tree Collapse file tree 3 files changed +10
-1
lines changed Original file line number Diff line number Diff line change 3131- Fixed named backreferences in ` RegExp ` NCG polyfill
3232- Fixed some cases of ` RegExp ` NCG polyfill in combination with other types of groups
3333- Fixed some cases of ` RegExp ` NCG polyfill in combination with ` dotAll `
34+ - Fixed ` RegExp ` ` sticky ` polyfill with alternation
3435- Fixed handling of some line terminators in case of ` multiline ` + ` sticky ` mode in ` RegExp ` polyfill
3536- Fixed ` .input ` slicing on result object with ` RegExp ` ` sticky ` mode polyfill
3637- Fixed handling of empty groups with ` global ` and ` unicode ` modes in polyfills
Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ if (PATCH) {
7979 var prevChar = re . lastIndex > 0 && charAt ( str , re . lastIndex - 1 ) ;
8080 if ( re . lastIndex > 0 &&
8181 ( ! re . multiline || re . multiline && prevChar !== '\n' && prevChar !== '\r' && prevChar !== '\u2028' && prevChar !== '\u2029' ) ) {
82- source = '(?: ' + source + ')' ;
82+ source = '(?: (?: ' + source + ') )' ;
8383 strCopy = ' ' + strCopy ;
8484 charsAdded ++ ;
8585 }
Original file line number Diff line number Diff line change @@ -94,4 +94,12 @@ if (DESCRIPTORS) {
9494 regex5 . lastIndex = 2 ;
9595 assert . deepEqual ( regex5 . exec ( '.\u2029bar' ) , [ 'bar' ] , 'multiline sticky after \\u2029' ) ;
9696 } ) ;
97+
98+ QUnit . test ( 'RegExp#exec sticky with alternation' , assert => {
99+ const re = new RegExp ( 'a|b' , 'y' ) ;
100+ re . lastIndex = 1 ;
101+ const result = re . exec ( 'cb' ) ;
102+ assert . deepEqual ( result , [ 'b' ] , 'alternation matches non-first alternative at lastIndex' ) ;
103+ assert . same ( re . lastIndex , 2 , 'lastIndex updated correctly' ) ;
104+ } ) ;
97105}
You can’t perform that action at this time.
0 commit comments