`document.defaultView` => `window`
|Reported by:||paul.irish||Owned by:||rwaldron|
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 6 years ago by rwaldron
- Component changed from unfiled to css
- Milestone changed from None to 1.next
- Owner set to rwaldron
- Priority changed from undecided to low
- Status changed from new to assigned
comment:5 Changed 5 years ago by Rick Waldron
- Resolution set to fixed
- Status changed from assigned to closed