Skip to content

Commit

Permalink
Merge pull request #783 from goldfiglabs/fix_ff_content_script
Browse files Browse the repository at this point in the history
Fixes #522 by binding `requestAnimationFrame` to `window`
  • Loading branch information
davidjbradshaw committed Dec 30, 2019
2 parents ca89bb2 + 33f6677 commit 92fc77f
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion js/iframeResizer.contentWindow.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion js/iframeResizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@

if (!requestAnimationFrame) {
log('setup', 'RequestAnimationFrame not supported')
} else {
// Firefox extension content-scripts have a globalThis object that is not the same as window.
// Binding `requestAnimationFrame` to window allows the function to work and prevents errors
// being thrown when run in that context, and should be a no-op in every other context.
requestAnimationFrame = requestAnimationFrame.bind(window);
}
}

Expand Down Expand Up @@ -175,7 +180,7 @@
var bot = compStyle.paddingBottom ? parseInt(compStyle.paddingBottom, 10) : 0
return top + bot
}

function getBorderEnds(compStyle) {
if (compStyle.boxSizing !== 'border-box') {
return 0;
Expand Down
2 changes: 1 addition & 1 deletion js/iframeResizer.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions js/iframeResizer.min.js

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion src/iframeResizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@

if (!requestAnimationFrame) {
log('setup', 'RequestAnimationFrame not supported')
} else {
// Firefox extension content-scripts have a globalThis object that is not the same as window.
// Binding `requestAnimationFrame` to window allows the function to work and prevents errors
// being thrown when run in that context, and should be a no-op in every other context.
requestAnimationFrame = requestAnimationFrame.bind(window);
}
}

Expand Down Expand Up @@ -175,7 +180,7 @@
var bot = compStyle.paddingBottom ? parseInt(compStyle.paddingBottom, 10) : 0
return top + bot
}

function getBorderEnds(compStyle) {
if (compStyle.boxSizing !== 'border-box') {
return 0;
Expand Down

0 comments on commit 92fc77f

Please sign in to comment.