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
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions src/yui/js/yui.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ available.

// bind the specified additional modules for this instance
if (!l) {
Y._afterConfig();
Y._setup();
}
}
Expand All @@ -145,6 +146,7 @@ available.
Y.applyConfig(args[i]);
}

Y._afterConfig();
Y._setup();
}

Expand Down Expand Up @@ -476,8 +478,7 @@ proto = {
throwFail: true,
useBrowserConsole: true,
useNativeES5: true,
win: win,
global: Function('return this')()
win: win
};

//Register the CSS stamp element
Expand Down Expand Up @@ -506,6 +507,25 @@ proto = {

},

/**
This method is called after all other configuration has been applied to
the YUI instance.

@method _afterConfig
@private
**/
_afterConfig: function () {
var Y = this;

// We need to set up Y.config.global after the rest of the configuration
// so that setting it in user configuration prevents the library from
// using eval(). This is critical for Content Security Policy enabled
// sites and other environments like Chrome extensions
if (!Y.config.hasOwnProperty('global')) {
Y.config.global = Function('return this')();
}
},

/**
Finishes the instance setup. Attaches whatever YUI modules were defined
at the time that this instance was created.
Expand Down