Skip to content
This repository was archived by the owner on Mar 13, 2018. It is now read-only.

Commit cdb189f

Browse files
committed
Merge pull request #470 from arv/get-default-computed-style
Wrap window getDefaultComputedStyle
2 parents 8041238 + 864ca98 commit cdb189f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/wrappers/Window.js

+18
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
var OriginalWindow = window.Window;
1818
var originalGetComputedStyle = window.getComputedStyle;
19+
var originalGetDefaultComputedStyle = window.getDefaultComputedStyle;
1920
var originalGetSelection = window.getSelection;
2021

2122
function Window(impl) {
@@ -27,6 +28,14 @@
2728
return wrap(this || window).getComputedStyle(unwrapIfNeeded(el), pseudo);
2829
};
2930

31+
// Mozilla proprietary extension.
32+
if (originalGetDefaultComputedStyle) {
33+
OriginalWindow.prototype.getDefaultComputedStyle = function(el, pseudo) {
34+
return wrap(this || window).getDefaultComputedStyle(
35+
unwrapIfNeeded(el), pseudo);
36+
};
37+
}
38+
3039
OriginalWindow.prototype.getSelection = function() {
3140
return wrap(this || window).getSelection();
3241
};
@@ -62,6 +71,15 @@
6271
}
6372
});
6473

74+
// Mozilla proprietary extension.
75+
if (originalGetDefaultComputedStyle) {
76+
Window.prototype.getDefaultComputedStyle = function(el, pseudo) {
77+
renderAllPending();
78+
return originalGetDefaultComputedStyle.call(unwrap(this),
79+
unwrapIfNeeded(el),pseudo);
80+
};
81+
}
82+
6583
registerWrapper(OriginalWindow, Window, window);
6684

6785
scope.wrappers.Window = Window;

0 commit comments

Comments
 (0)