LearnNewsExamplesConnect
Frontmatter
assignees[]
createdAtOct 22, 2026, 3:14 PM
updatedAtOct 22, 2026, 6:34 PM
githubUrlhttps://github.com/neomjs/neo/issues/20002
authorneo-opus-ada
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtOct 22, 2026, 6:34 PM

Rectangle#intersects returns a Boolean for a zero-size rectangle

Closed v13.3.1/archive-v13-3-1-chunk-1 enhancementgood first issueairefactoringcore
neo-opus-ada
neo-opus-ada commented on Oct 22, 2026, 3:14 PM

Context

Found while reviewing #19997. Neo.util.Rectangle#intersects(other) has two return types, and the size of the argument picks one silently:

  • An other with width and height: the overlap Rectangle, or false.
  • An other with zero width or height: a point-containment test, true or false.

A caller that chains on the result therefore breaks as soon as a zero-size box shows up. On #19997's first head, DomAccess#getClippedRect intersected a torn-out pane's display: none ancestor (a 0×0 rect) and got true. The next .intersects() threw rect.intersects is not a function as a page error, which failed the hosted multi-window e2e specs. #19997 guards that call site. The trap is still in the API.

Design authority: none recorded. intersects() has no JSDoc, and its only statement of intent is the inline comment on the point branch ("We're dealing with a point here - zero dimensions").

The Problem

  • One method carries two semantics, area overlap and point-in-rect, and only the caller's argument decides which.
  • With no JSDoc, nothing tells a caller the result can be true.
  • Three callers use the point branch deliberately and pass a point-shaped object ({bottom: y, right: x, x, y}). contains() is not a drop-in for them: it delegates to Rectangle.includes(), which reads left/top, and those objects don't have them.

The Architectural Reality

  • src/util/Rectangle.mjs: intersects() (the area branch and the point branch), contains() and the static includes() (left/top/right/bottom), and the static getIntersection().
  • Point callers: src/manager/Window.mjs (the window under a screen point) and src/manager/DragCoordinator.mjs (twice, cross-window targeting). All three pass {bottom: y, right: x, x, y}.
  • Area caller: src/main/DomAccess.mjs#getClippedRect, guarded by #19997.

The Fix

  1. intersects(other) always returns the overlap Rectangle or false. A zero-size other returns false, because it has no visible overlap.
  2. Point containment gets its own method, for example containsPoint(x, y), and the three point callers move to it.
  3. Both methods get JSDoc, including their return types.

Acceptance Criteria

  • intersects() never returns true. Unit cases cover an overlapping, a disjoint, a touching and a zero-size other.
  • containsPoint() has unit cases for points inside, on the edge and outside.
  • Window.mjs and DragCoordinator.mjs use containsPoint(), and their existing unit and e2e coverage stays green.
  • No caller in src/, apps/ or examples/ still relies on a Boolean from intersects().

Out of Scope

  • Changing the semantics of includes() or contains().

Related

Live latest-open sweep: checked latest 20 open issues at 2026-10-22T13:12:53Z; no equivalent found. Keyword sweep: gh issue list --search "Rectangle intersects" (all states): no match (only #17578, unrelated). A2A claim sweep: last 15 lane-claims; no overlapping scope. MC sweep: "Rectangle intersects returns boolean zero width height point": no prior decision. Own-assignment sweep: none overlapping.

Origin Session ID: 678d216d-f4f7-41da-80d7-136e627522ff Retrieval Hint: "Rectangle intersects mixed return Boolean zero-size point branch, getClippedRect page error"

arnavsingh0418 cross-referenced by PR #20007 on Oct 22, 2026, 4:52 PM
tobiu referenced in commit 3f27e5f - "fix(util): Rectangle#intersects never returns a Boolean; add containsPoint() (#20002) (#20007) on Oct 22, 2026, 6:34 PM
tobiu closed this issue on Oct 22, 2026, 6:34 PM