WhyTan00 opened a new pull request, #21828:
URL: https://github.com/apache/echarts/pull/21828

   ## Brief Information
   
   This pull request is in the type of:
   
   - [x] bug fixing
   - [ ] new feature
   - [ ] others
   
   ### What does this PR do?
   
   Keep missing dataset values from matching regular expression filters as the 
literal strings `"null"` or `"undefined"`.
   
   ### Fixed issues
   
   No existing issue was found in the targeted search. The reproduction is 
included below.
   
   ## Details
   
   ### Before: What was the problem?
   
   `RegExpEvaluator.evaluate` passes the result of `typeof lVal` to `isString` 
and `isNumber`. Since every `typeof` result is itself a string, the string 
branch always runs. `RegExp.test` then coerces missing values to strings 
instead of reaching the existing non-string/non-number `false` branch.
   
   For example, use this normal dataset filter:
   
   ```js
   const source = [
       { id: 'missing-null', value: null },
       { id: 'missing-undefined', value: undefined },
       { id: 'missing-property' },
       { id: 'literal-null', value: 'null' },
       { id: 'literal-undefined', value: 'undefined' },
       { id: 'number', value: 42 },
       { id: 'numeric-string', value: '42' }
   ];
   const dataset = [
       { dimensions: ['id', 'value'], source },
       { transform: { type: 'filter', config: { dimension: 'value', reg: 
'^null$' } } }
   ];
   ```
   
   Before this fix, `^null$` selects both `missing-null` and `literal-null`. 
Replacing the condition with `^undefined$` selects `missing-undefined`, 
`missing-property`, and `literal-undefined`. The same happens with `RegExp` 
objects instead of string conditions. `null`/`undefined` are supported 
`OptionDataValue` values; absent properties in object rows also yield 
`undefined` through the normal source provider.
   
   ### After: How does it behave after the fixing?
   
   Check the original value with `isString(lVal)` / `isNumber(lVal)` so the 
existing type guard works as intended. The two filters select only their 
corresponding literal strings. Numbers still match their string representation: 
`^42$` selects both `number` and `numeric-string`.
   
   The change is limited to the guard. No comparator API, transform 
registration, or global/sticky regular expression `lastIndex` policy is changed.
   
   ## Document Info
   
   - [x] This PR doesn't relate to document changes
   - [ ] The document should be updated later
   - [ ] The document changes have been made in apache/echarts-doc#xxx
   
   ## Misc
   
   ### Security Checking
   
   - [ ] This PR uses security-sensitive Web APIs.
   
   ### ZRender Changes
   
   - [ ] This PR depends on ZRender changes (ecomfe/zrender#xxx).
   
   ### Related test cases or examples to use the new APIs
   
   Added 10 regressions through the real `createSource` / `applyDataTransform` 
/ built-in filter path, covering array rows, object rows, missing vs literal 
values, both supported regexp condition forms, valid numeric matches, and 
logical/piped filters. No comparator or classifier is mocked.
   
   On the unchanged base, 6 of the new tests fail and 4 pass. With the fix, all 
10 new tests and the 8 existing data-transform tests pass:
   
   ```sh
   ./node_modules/.bin/jest --config test/ut/jest.config.cjs --runInBand 
--coverage=false --runTestsByPath test/ut/spec/data/filterTransform.test.ts 
test/ut/spec/data/dataTransform.test.ts
   ./node_modules/.bin/eslint src/util/conditionalExpression.ts
   git diff --check
   ```
   
   The direct CLI source-module reproduction also confirms the before/after 
filtered rows. No browser or visual rendering is claimed; this is a 
data-filtering change, and the existing Jest data-transform suite uses 
jsdom/canvas mocks.
   
   Local environment: Node 24.22.1, TypeScript 4.4.3, Jest 26.6.3, zrender 
6.1.0. The canonical root and bmap typecheck commands were attempted but are 
blocked by 1,364 parse errors in the installed `@types/node` and 
`@types/babel__traverse` declarations. They are not reported as passing; no 
dependency or TypeScript configuration changes are included.
   
   ### Merging options
   
   - [x] Please squash the commits into a single one when merging.
   
   ### Other information
   
   OpenAI Codex assisted with the unchanged-source reproduction, narrow guard 
change, regression tests, and verification described above.
   
   <!-- oss-publication-operation: f5b1790e-a492-42e0-97ee-8c259779f13f -->
   


-- 
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