Skip to content

Commit 0cadf8d

Browse files
resurtmmarcj
authored andcommitted
Fix Firefox extension content script #257 (#258)
1 parent 7587a65 commit 0cadf8d

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/ResizeSensor.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,21 @@
1919
if (typeof window === "undefined") {
2020
return null;
2121
}
22+
// https://github.com/Semantic-Org/Semantic-UI/issues/3855
23+
// https://github.com/marcj/css-element-queries/issues/257
24+
var globalWindow = typeof window != 'undefined' && window.Math == Math
25+
? window
26+
: typeof self != 'undefined' && self.Math == Math
27+
? self
28+
: Function('return this')();
2229
// Only used for the dirty checking, so the event callback count is limited to max 1 call per fps per sensor.
2330
// In combination with the event based resize sensor this saves cpu time, because the sensor is too fast and
2431
// would generate too many unnecessary events.
25-
var requestAnimationFrame = window.requestAnimationFrame ||
26-
window.mozRequestAnimationFrame ||
27-
window.webkitRequestAnimationFrame ||
32+
var requestAnimationFrame = globalWindow.requestAnimationFrame ||
33+
globalWindow.mozRequestAnimationFrame ||
34+
globalWindow.webkitRequestAnimationFrame ||
2835
function (fn) {
29-
return window.setTimeout(fn, 20);
36+
return globalWindow.setTimeout(fn, 20);
3037
};
3138

3239
/**

0 commit comments

Comments
 (0)