-
Notifications
You must be signed in to change notification settings - Fork 383
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid CSP errors in Chrome apps by using global var detection.
Fixes #301.
- Loading branch information
Showing
1 changed file
with
9 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2367e09
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ljharb Awesome! ⛵
(I think you can remove the
/*jshint evil: true/false */
comments now)2367e09
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, true
2367e09
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 2f9f81c
2367e09
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd add few more checks to avoid false positives when we have a
self
orwindow
global variable that is not the global object itself like I do here in the-global-object:It checks for circular reference that should be there for the real global object and the presence and correct values of
Array
andsetInterval
properties, which are arbitrarily chosen but unlikely to be there by accident.See https://github.com/rsp/node-the-global-object/blob/master/index.js
Hopefully, this will not be needed when tc39/proposal-global#12 is universally supported, which I'm looking forward tp.
2367e09
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is largely unnecessary, since shims need to be loaded before any other code to work properly.