#10373 closed enhancement (fixed)
`document.defaultView` => `window`
Reported by: | paul.irish | Owned by: | Rick Waldron |
---|---|---|---|
Priority: | low | Milestone: | 1.8 |
Component: | css | Version: | git |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
grabbing getComputedStyle
off of defaultView has been commonplace for many years, but its unnecessary.
the same function has worked off the global window object all the way back, AFAICT.
I posted about this on g+ ...
oftentimes you see document.defaultView.getComputedStyle used instead of the getComputedStyle that's on the window object. I imagine that's because the spec'd "interface" that getComputedStyle was defined for defaultView before it was decided that the global object inherited the defaultView interface. http://www.w3.org/TR/DOM-Level-2-Style/css.html#CSS-OverrideAndComputed
Regardless, we now have a lot of code with this
defaultView
action, but I feel like its unnecessary. Funnily enough, check out this confused code example from PPK:
else if (window.getComputedStyle) var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
Does anyone know the last browser that had gCS available on d.dV but not on window?
and david baron responded...
I don't think there were any. I'd guess the whole defaultView business was some combination of (1) not wanting to write a spec for window and (2) making an API that was also usable in Java.
grabbing the more convenient gCS will kill off a lot of bytes and some extra conditional complexity.
Change History (8)
comment:1 Changed 12 years ago by
Component: | unfiled → css |
---|---|
Milestone: | None → 1.next |
Owner: | set to Rick Waldron |
Priority: | undecided → low |
Status: | new → assigned |
comment:2 Changed 12 years ago by
comment:3 Changed 11 years ago by
Milestone: | 1.next → 1.8 |
---|
can you please resubmit this now that FF3.6 is gone?
comment:4 Changed 11 years ago by
In at least a few places, it seems we're doing this because the element we're interrogating may be in another frame. So it's not the global window object. There isn't a lot to be gained in any case, since there are very few uses at this point. I would be happy with this just being closed if there isn't a compelling reason to make changes.
comment:5 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Update document.defaultView.getComputedStyle. Fixes #10373
Changeset: f7ee1f6e59f0b465f5f64bf6ac52108e445efaac
comment:6 Changed 11 years ago by
This breaks for a test framework I work on: FuncUnit. FuncUnit opens a popup window with the application under test, and the parent window runs commands in that window. In IE, window.getComputedStyle(elem) breaks, because window is the opener window, but elem is in the popup window. elem.ownerDocument.defaultView.getComputedStyle(elem) works fine, because it gets the relevant document. Can the window part of this commit be reverted for this reason?
comment:7 follow-up: 8 Changed 11 years ago by
@brian, can you create a new ticket for this? It seems like it would be reasonable. A simple test case would help as well.
comment:8 Changed 10 years ago by
Replying to dmethvin:
@brian, can you create a new ticket for this? It seems like it would be reasonable. A simple test case would help as well.
I've just created a ticket which I believe describes this behaviour - http://bugs.jquery.com/ticket/14150
https://github.com/rwldrn/jquery/pull/new/10373