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

Commit

Permalink
Merge pull request #470 from arv/get-default-computed-style
Browse files Browse the repository at this point in the history
Wrap window getDefaultComputedStyle
  • Loading branch information
dfreedm committed Aug 4, 2014
2 parents 8041238 + 864ca98 commit cdb189f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/wrappers/Window.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

var OriginalWindow = window.Window;
var originalGetComputedStyle = window.getComputedStyle;
var originalGetDefaultComputedStyle = window.getDefaultComputedStyle;
var originalGetSelection = window.getSelection;

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

// Mozilla proprietary extension.
if (originalGetDefaultComputedStyle) {
OriginalWindow.prototype.getDefaultComputedStyle = function(el, pseudo) {
return wrap(this || window).getDefaultComputedStyle(
unwrapIfNeeded(el), pseudo);
};
}

OriginalWindow.prototype.getSelection = function() {
return wrap(this || window).getSelection();
};
Expand Down Expand Up @@ -62,6 +71,15 @@
}
});

// Mozilla proprietary extension.
if (originalGetDefaultComputedStyle) {
Window.prototype.getDefaultComputedStyle = function(el, pseudo) {
renderAllPending();
return originalGetDefaultComputedStyle.call(unwrap(this),
unwrapIfNeeded(el),pseudo);
};
}

registerWrapper(OriginalWindow, Window, window);

scope.wrappers.Window = Window;
Expand Down

0 comments on commit cdb189f

Please sign in to comment.