TARUNTEjjjj commented on code in PR #21829:
URL: https://github.com/apache/echarts/pull/21829#discussion_r4604452095


##########
src/util/conditionalExpression.ts:
##########
@@ -175,8 +175,9 @@ class RegExpEvaluator implements FilterComparator {
 
     constructor(rVal: unknown) {
         // Support condVal: RegExp | string
+        // Keep the evaluator's lastIndex separate from the caller's regexp.
         const condValue = this._condVal = isString(rVal) ? new RegExp(rVal)
-            : isRegExp(rVal) ? rVal as RegExp
+            : isRegExp(rVal) ? new RegExp(rVal)

Review Comment:
   The evaluator-owned clone also makes frozen regexp configurations work, 
which is useful coverage for callers that freeze shared configuration. I 
checked `Object.freeze(/alpha/gi)` through the real `createSource` → 
`applyDataTransform` filter path with rows `[['first','ALPHA'], 
['nonmatch','beta'], ['second','ALPHA']]`. Both matching rows are retained on 
two successive runs, and the original regexp remains frozen with `lastIndex === 
0`.
   
   Reverting the production diff to its original implementation makes this same 
test throw `TypeError: Cannot assign to read only property 'lastIndex'` from 
`RegExp.test`. With the patch, this extra case and all 21 existing regexp tests 
pass. It may be worth adding the frozen-regexp case alongside the existing 
caller-cursor test to protect the ownership guarantee.
   
   Validation used Node 26.13.0 and Jest/jsdom; no browser rendering is 
claimed. AI-assisted review and local validation with OpenAI Codex.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to