| Summary: | Web Inspector: REGRESSION(r242018): using `RegExp.prototype.test` with a global `RegExp` will ignore one potential match after each successful match | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Devin Rousso <hi> | ||||||
| Component: | Web Inspector | Assignee: | Devin Rousso <hi> | ||||||
| Status: | RESOLVED FIXED | ||||||||
| Severity: | Normal | CC: | bburg, hi, inspector-bugzilla-changes, timothy, webkit-bug-importer | ||||||
| Priority: | P2 | Keywords: | InRadar | ||||||
| Version: | WebKit Local Build | ||||||||
| Hardware: | All | ||||||||
| OS: | All | ||||||||
| Bug Depends on: | 192527 | ||||||||
| Bug Blocks: | |||||||||
| Attachments: |
|
||||||||
Created attachment 396795 [details]
Patch
Created attachment 396797 [details]
Patch
use better names :P
Committed r260291: <https://trac.webkit.org/changeset/260291> All reviewed patches have been landed. Closing bug and clearing flags on attachment 396797 [details]. (In reply to Devin Rousso from comment #0) > ``` > let x = /script/gi; > console.log(x.test("script")); // true > console.log(x.test("script")); // false > console.log(x.test("script")); // true > console.log(x.test("script")); // false > ``` > > this is due to the nature of `lastIndex`, which is set when using a global > `RegExp` (see 12.a in <https://tc39.es/ecma262/#sec-regexpbuiltinexec>) Wut. |
``` let x = /script/gi; console.log(x.test("script")); // true console.log(x.test("script")); // false console.log(x.test("script")); // true console.log(x.test("script")); // false ``` this is due to the nature of `lastIndex`, which is set when using a global `RegExp` (see 12.a in <https://tc39.es/ecma262/#sec-regexpbuiltinexec>)