Opened 10 years ago
Closed 10 years ago
#13760 closed bug (fixed)
getComputedStyle no longer works in node with jsdom
Reported by: | m_gol | Owned by: | |
---|---|---|---|
Priority: | high | Milestone: | None |
Component: | build | Version: | 2.0.0-beta3 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description (last modified by )
I've noticed in this pull request:
https://github.com/jquery/jquery/pull/1103
a change to the parameter passed to the main enclosing IIFE, i.e. window was changed to this. The problem is, there are lots of places in jQuery where we assume window is actually window so it breaks a lot. One example is in css.js:
// NOTE: we've included the "window" in window.getComputedStyle // because jsdom on node.js will break without it. function getStyles( elem ) { return window.getComputedStyle( elem, null ); }
So we have a few bytes (window.
) that actually fix nothing. Another example is window.addEventListener etc.
Change History (7)
comment:1 Changed 10 years ago by
comment:2 Changed 10 years ago by
What a nightmare. There are way too many places where we need window to be _window_
comment:3 Changed 10 years ago by
Dave suggested we could just pass window instead of this and thus attach jQuery to window. jQuery is exported for node separately, anyway, so it shouldn't break.
If we need the global object inside, too, though, I see no other option than
(function ( global, window ) { /* code */ })( this, window );
comment:4 Changed 10 years ago by
Component: | unfiled → build |
---|---|
Priority: | undecided → high |
Status: | new → open |
If I understand this correctly, jQuery won't work without jsdom and its window export, which means using node's global object isn't sufficient on its own. So, just passing window and continuing to assign to module.exports in the outro is probably the best option.
comment:5 Changed 10 years ago by
Description: | modified (diff) |
---|
comment:6 Changed 10 years ago by
It's actually not src/outro, it's in src/exports.
Pull request: https://github.com/jquery/jquery/pull/1238
comment:7 Changed 10 years ago by
Resolution: | → fixed |
---|---|
Status: | open → closed |
Fixes #13760. Pass window, not this to the main IIFE. Closes gh-1238
Changeset: e80117adb49eff8f82140b01d755bdeefe7eb089
I meant "a few bytes that fix nothing", not "save".