Repository navigation
Keep escaped anchor selectors updating - #1286
danielbarion merged 2 commits into
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
danielbarion
left a comment
There was a problem hiding this comment.
Thanks for the fix, I didn't realized that issue before!
Can you please update the regex code by the comment I did?
| const match = selector.match(/^\[data-tooltip-id=(['"])((?:\\.|(?!\1).)*)\1\]$/) | ||
|
|
||
| if (!match) { | ||
| if (!match || /\\(?!['"])/.test(match[2])) { |
There was a problem hiding this comment.
Can you please improve that hard-coded regex in the conditional by adding it into a constant before it? Also can you please add two straightforward comments before each variable explaining it?
With five or more tooltip selectors, anchors matched by CSS escapes such as
[data-tooltip-id='\61 nchor']stop updating when elements are inserted or their IDs change. The registry compares the escaped text with the unescaped dataset value.Reuse the selector parser and route escapes it cannot decode through the existing native selector fallback. Plain IDs and escaped quotes keep their fast path.
Three regressions fail before this change and pass afterward. TypeScript and changed-file ESLint/Prettier pass. The full Jest run passed 179 tests and 8 snapshots but had three imperative/delay failures; the numeric-zero imperative failure also reproduces on unchanged HEAD, while the two delay failures vary between runs. All bundle builds and declarations pass. Browser matrix not run.
Summary by CodeRabbit
data-tooltip-idselectors. Hexadecimal and backslash escapes now remain consistent with native selector matching, while escaped apostrophes continue to be handled correctly. This helps ensure tooltip anchors are detected and updates are reported accurately when matching anchors are added or removed.