Merge query helpers into one scopedQuery module - #2
Open
myabc wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR consolidates the internal DOM query helpers into a single scopedQuery(root, selector) module with a unified guard + invalid-selector warn-once policy, and updates call sites/tests accordingly. It also changes the warn-once registry to be scoped per root element (via WeakMap) and removes the prior test-only reset hook.
Changes:
- Replace duplicated
queryOne/queryAllwithscopedQuery()returning{ first, all, exists }. - Scope invalid-selector warnings per root element using
WeakMap<Element, Set<string>>, removingresetSelectorWarnings. - Update tests and blessing call sites to use the new API and document the decision in
CONTEXT.md(+ changeset).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| test/query.test.ts | Migrates unit tests to scopedQuery() and adds per-root warn-once expectations. |
| test/integration.test.ts | Removes now-unneeded resetSelectorWarnings() usage. |
| test/blessing.test.ts | Removes now-unneeded resetSelectorWarnings() usage/import. |
| src/query.ts | Introduces scopedQuery() and per-root warning registry via WeakMap. |
| src/blessing.ts | Refactors element accessors to use scopedQuery().first/all/exists. |
| CONTEXT.md | Documents “scoped query” and the per-root warn-once policy. |
| .changeset/quick-moles-search.md | Adds patch changeset describing the internal refactor + observable warn scoping change. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
3 tasks
myabc
force-pushed
the
refactor/scoped-query
branch
from
August 10, 2026 18:50
ee0a57a to
2439513
Compare
This was referenced Aug 10, 2026
myabc
force-pushed
the
refactor/scoped-query
branch
from
August 10, 2026 19:40
2439513 to
364367d
Compare
3 tasks
myabc
force-pushed
the
refactor/scoped-query
branch
from
August 10, 2026 20:48
364367d to
5e3e085
Compare
queryOne and queryAll duplicated 16 lines each (falsy-root guard,
empty-selector check, try/catch, warn-once) differing by two tokens,
and the warn-once registry was a process-global Set whose only reset
was a test-only export hidden from the barrel — a seam cut for the
test harness, not for callers.
- replace both with scopedQuery(root, selector) returning
{ first, all, exists }; guard, error policy, and warn-once live
behind one interface
- key the warn registry per root element via WeakMap: warning
lifetime becomes an implementation detail, dies with the element,
and tests need no reset hook
- delete resetSelectorWarnings and its imports from blessing and
integration tests
- record the scoped-query term and warn-once decision in CONTEXT.md
myabc
force-pushed
the
refactor/scoped-query
branch
from
August 10, 2026 20:49
5e3e085 to
9551a8c
Compare
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ticket
N/A — internal architecture review of this library.
What are you trying to accomplish?
Collapse two shallow query helpers into one deep module.
queryOne/queryAllduplicated 16 lines each (guard, selector check, try/catch, warn-once) differing by two tokens, and the warn-once registry was a process-globalSetwhose only reset was a test-only export hidden from the barrel.What approach did you choose and why?
scopedQuery(root, selector)→{ first, all, exists }. Guard, error policy, and warn-once live behind one seam;blessing.tscall sites collapse onto it.WeakMap— lifetime becomes an implementation detail, dies with the element, tests need no reset hook.resetSelectorWarningsdeleted (keeping the globalSet+ reset export would keep a test-only seam in production surface).CONTEXT.mdrecords the term + decision.No public API change; patch changeset for the observable warn-scoping change.
Stacked on #1 (rewrote the
blessing.tscall sites this touches). Chain: #6 ← #1 ← this ← #4.Verification:
bun test42 pass,bun run typecheckclean,bun run buildclean.Merge checklist
Lookbook docsn/a — npm library; CONTEXT.md updatedTested major browsersn/a — internal refactor, behavior unchanged