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

Commit

Permalink
Wrap window getDefaultComputedStyle
Browse files Browse the repository at this point in the history
getDefaultComputedStyle is a Mozilla proprietary extension but
jQuery uses it so we have no choice but to support it.

Fixes https://github.com/Polymer/platform-dev/issues/32
  • Loading branch information
arv committed Jul 18, 2014
1 parent 67607e7 commit 864ca98
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 864ca98

Please sign in to comment.