fix(core): skip data-highlight-exclude subtrees in the live selection#51
Conversation
The selection marker paints by range geometry, which covers user-select:none text too, so a select-all banded over opted-out subtrees. highlightSelection now carves [data-highlight-exclude] out of the painted ranges, keeping the runs around them whole. Mark the docs demo cards so Cmd+A no longer paints their read-only quote and legend. Document the behaviour in the README and the highlightSelection JSDoc.
Review summaryClean, focused fix — no blocking issues. What it does. Integration. One call site in Tests. 4 new cases cover the interesting shapes (middle, whole-range, none, multiple). Good coverage. Security / Safety / Performance. Nothing to flag. Two non-blocking nits posted inline (comment verbosity, outermost-only filter simplification). LGTM — ship it. |
- replace the quadratic outermost-only scan with an ancestor closest() check - trim the PaperCard opt-out comment to one line
Review — clean ✅Reviewed all 6 changed files (116 additions) across security, performance, safety, and format. No blocking issues. No new inline comments. What I checked
Previous commentsBoth prior nits (O(n²) outermost-only scan → Notes
|
Summary
highlightSelectionnow carves[data-highlight-exclude]subtrees out of the painted selection ranges. The live marker paints by range geometry (getClientRects), which coversuser-select: nonetext too, so a select-all (Cmd/Ctrl+A) previously banded over opted-out regions. The runs around excluded elements keep their exact geometry, and the document's own selection is left untouched, so single-range browsers are unaffected.excludeMarkedSubtrees()in the targeting layer, reusing the existingisExcluded/EXCLUDE_ATTRlogic that the page-scan path already had, plus regression tests.PaperCard) are markeddata-highlight-exclude, so Cmd+A no longer paints their read-only quote text and the Highlight/Underline/Overline/Strike legend.highlightSelectionJSDoc note that the attribute is honoured by the live marker.Test plan
coreunit tests pass (212, including 4 newexcludeMarkedSubtreestests)coretypecheck cleanwebsitetypecheck clean/docs: after Cmd+A the global marker paints the page prose (126 bands) and 0 bands land over any demo card — quote and legend stay clean, while each card's own intended highlight remains