Repository navigation
fix(mvc.$): make $(window) hold the window - #3542
Merged
Merged
Conversation
MartinKanera
force-pushed
the
fix/mvc-dom-window
branch
from
October 12, 2026 06:31
15086fe to
9d2768b
Compare
MartinKanera
marked this pull request as ready for review
October 12, 2026 07:08
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unguarded collection-building APIs can still contain windows, causing regressions in width() and height().
1 open finding
What changed in this PR
This PR makes mvc.$ reject window objects instead of silently wrapping them.
Changes:
- Detect windows in direct and array-like inputs.
- Remove window-specific measurement handling.
- Add QUnit coverage and a patch changeset.
| File | Description |
|---|---|
Dom.mjs |
Rejects window-containing inputs. |
methods.mjs |
Removes viewport measurement branches. |
mvc.Dom.js |
Tests direct, iframe, and array-contained windows. |
| Changeset | Documents the behavioral change. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
MartinKanera
marked this pull request as draft
October 12, 2026 14:31
Since 4.0.0, $(window) fell through to the array-like branch and copied window.length items, which counts the page's frames: it held nothing on a page without iframes and the frames' windows otherwise. The event methods bound nothing and the window branches of width() and height() were unreachable. The constructor now holds any window as a one-item collection, and width()/height() accept any window, so an iframe's window measures its own document. The other methods still have no window case.
MartinKanera
force-pushed
the
fix/mvc-dom-window
branch
from
October 12, 2026 15:42
11a14bf to
b80d47e
Compare
The scrollable-window helper scrolled the window back to the top after each test, but no test scrolls the window.
MartinKanera
marked this pull request as ready for review
October 12, 2026 16:11
MartinKanera
requested review from
kumilingus
and removed request for
kumilingus
October 12, 2026 16:11
kumilingus
approved these changes
Oct 12, 2026
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.

Summary
mvc.$(window)has returned an empty collection since 4.0.0. A window has nonodeType, so theDomconstructor treats it as an array-like and copieswindow.lengthitems, which are the page's frames. Events bound through it go nowhere, and theel === windowbranches ofwidth()/height()are unreachable through$(window). With this change,$(window)holds the window, so the event methods andwidth()/height()work on it.Changes
Domconstructor: holds any window, an iframe'scontentWindowincluded, as a one-item collection. The check uses jQuery's window test (obj != null && obj === obj.window) right after the DOM-element branch, so on a page with iframes$(window)holds the window instead of its frames.width()andheight(): test for any window instead ofel === window, so an iframe's window measures its own document.on(),one(),off(),width()andheight()support a window, and a comment on the constructor branch says so. Theprop()aliases (innerWidth(),outerWidth(),scrollTop(), ...) readundefinedand their setters write a plain property onto the window. Most other element methods throw aTypeError.$():$(el).add(window)adds the window.closest(window),appendTo(window),prependTo(window)and a view withel: windowthrow aTypeError, as they already did on a page with an iframe.$(window.parent)holds the parent window instead of the parent's frames, and aone()handler bound through$([window])now removes itself after it runs.$(window)module that pins the constructor (alone, on a page with an iframe, and an iframe's window),width()/height()on the window and on an iframe's window, andon(),one()andoff().patchchangeset for@joint/core.Verification
yarn workspace @joint/core lint: passyarn workspace @joint/core test: pass (Karma 2146/2146, geometry 350/350, vectorizer 453/453, mocha, qunit, TypeScript; coverage thresholds included)width()/height()test still failed with aTypeError. Awidth()that returnswindow.innerWidthfails the scrollbar test, and so does aheight()that returnswindow.innerHeight.yarn changeset status --since=upstream/master:@joint/corepatch$(window)