Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup Y.config.global only if no user global was provided #1963

Closed
wants to merge 1 commit into from

Conversation

juandopazo
Copy link
Member

The goal behind this change is to allow for YUI to work on CSP regulated sites and environments like Chrome extensions by providing the global in the user configuration. Setting Y.config.global in the user configuration doesn't trigger the use of Function to get to the global object.

No idea how to test the side-effects of this change.

/cc @caridy @tripp

@yahoocla
Copy link

CLA is valid!

@caridy
Copy link
Member

caridy commented Sep 24, 2014

💯

@okuryu
Copy link
Member

okuryu commented Sep 25, 2014

This still gets warning CSP, is this just as you expected?
2014-09-25 at 20 18

Why not following? Was I wrong?

diff --git a/src/yui/js/yui.js b/src/yui/js/yui.js
index c93f011..580b33f 100644
--- a/src/yui/js/yui.js
+++ b/src/yui/js/yui.js
@@ -153,7 +153,7 @@ available.
         return Y;
     };

-(function() {
+(function(global) {

     var proto, prop,
         VERSION = '@VERSION@',
@@ -477,7 +477,7 @@ proto = {
             useBrowserConsole: true,
             useNativeES5: true,
             win: win,
-            global: Function('return this')()
+            global: global
         };

         //Register the CSS stamp element
@@ -1639,7 +1639,7 @@ Y.log('Fetching loader: ' + config.base + config.loaderPath, 'info', 'yui');
     }

     YUI.Env[VERSION] = {};
-}());
+}(this));

@caridy
Copy link
Member

caridy commented Sep 25, 2014

yeah, this PR is not attempting to fix it, but to provide a way to workaround it. basically, you can now do: YUI({ global: window }) and the CSP warning will go away.

@tripp
Copy link
Contributor

tripp commented Sep 25, 2014

Cherry-picked into dev-master.

@tripp tripp closed this Sep 25, 2014
@okuryu
Copy link
Member

okuryu commented Sep 25, 2014

yeah, this PR is not attempting to fix it, but to provide a way to workaround it. basically, you can now do: YUI({ global: window }) and the CSP warning will go away.

Ah, gotcha. Thanks explaining.

@okuryu
Copy link
Member

okuryu commented Sep 29, 2014

Updated the HISTORY.md in 578344f.

@juandopazo
Copy link
Member Author

@okuryu thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants