diff --git a/app/code/Magento/RequireJs/Block/Html/Head/Config.php b/app/code/Magento/RequireJs/Block/Html/Head/Config.php index 9e89a18a03c96..050a19c0026e5 100644 --- a/app/code/Magento/RequireJs/Block/Html/Head/Config.php +++ b/app/code/Magento/RequireJs/Block/Html/Head/Config.php @@ -123,18 +123,18 @@ protected function _prepareLayout() $after = $staticAsset->getFilePath(); } } - $requireJsConfig = $this->fileManager->createRequireJsConfigAsset(); - $assetCollection->insert( - $requireJsConfig->getFilePath(), - $requireJsConfig, - $after - ); $requireJsMixinsConfig = $this->fileManager->createRequireJsMixinsAsset(); $assetCollection->insert( $requireJsMixinsConfig->getFilePath(), $requireJsMixinsConfig, $after ); + $requireJsConfig = $this->fileManager->createRequireJsConfigAsset(); + $assetCollection->insert( + $requireJsConfig->getFilePath(), + $requireJsConfig, + $after + ); return parent::_prepareLayout(); } } diff --git a/app/code/Magento/Theme/view/base/requirejs-config.js b/app/code/Magento/Theme/view/base/requirejs-config.js index 3ca6151895e98..55cf1783e76cf 100644 --- a/app/code/Magento/Theme/view/base/requirejs-config.js +++ b/app/code/Magento/Theme/view/base/requirejs-config.js @@ -83,9 +83,3 @@ var config = { } } }; - -require(['jquery'], function ($) { - 'use strict'; - - $.noConflict(); -}); diff --git a/lib/web/mage/requirejs/mixins.js b/lib/web/mage/requirejs/mixins.js index bebd10b1d6ee3..b9cedb40a756e 100644 --- a/lib/web/mage/requirejs/mixins.js +++ b/lib/web/mage/requirejs/mixins.js @@ -253,4 +253,11 @@ require([ return queueItem; }; + + require(['jquery'], function ($) { + 'use strict'; + + $.noConflict(); + }); + }); diff --git a/lib/web/requirejs/require.js b/lib/web/requirejs/require.js index 424e7386e9855..fed3ec90f845a 100644 --- a/lib/web/requirejs/require.js +++ b/lib/web/requirejs/require.js @@ -1,5 +1,5 @@ /** vim: et:ts=4:sw=4:sts=4 - * @license RequireJS 2.3.6 Copyright jQuery Foundation and other contributors. + * @license RequireJS 2.3.7 Copyright jQuery Foundation and other contributors. * Released under MIT license, https://github.com/requirejs/requirejs/blob/master/LICENSE */ //Not using strict: uneven strict support in browsers, #392, and causes @@ -11,7 +11,7 @@ var requirejs, require, define; (function (global, setTimeout) { var req, s, head, baseElement, dataMain, src, interactiveScript, currentlyAddingScript, mainScript, subPath, - version = '2.3.6', + version = '2.3.7', commentRegExp = /\/\*[\s\S]*?\*\/|([^:"'=]|^)\/\/.*$/mg, cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g, jsSuffixRegExp = /\.js$/, @@ -26,14 +26,15 @@ var requirejs, require, define; // then 'complete'. The UA check is unfortunate, but not sure how //to feature test w/o causing perf issues. readyRegExp = isBrowser && navigator.platform === 'PLAYSTATION 3' ? - /^complete$/ : /^(complete|loaded)$/, + /^complete$/ : /^(complete|loaded)$/, defContextName = '_', //Oh the tragedy, detecting opera. See the usage of isOpera for reason. isOpera = typeof opera !== 'undefined' && opera.toString() === '[object Opera]', contexts = {}, cfg = {}, globalDefQueue = [], - useInteractive = false; + useInteractive = false, + disallowedProps = ['__proto__', 'constructor']; //Could match something like ')//comment', do not lose the prefix to comment. function commentReplace(match, singlePrefix) { @@ -94,7 +95,7 @@ var requirejs, require, define; function eachProp(obj, func) { var prop; for (prop in obj) { - if (hasProp(obj, prop)) { + if (hasProp(obj, prop) && disallowedProps.indexOf(prop) == -1) { if (func(obj[prop], prop)) { break; } @@ -359,7 +360,7 @@ var requirejs, require, define; if (isBrowser) { each(scripts(), function (scriptNode) { if (scriptNode.getAttribute('data-requiremodule') === name && - scriptNode.getAttribute('data-requirecontext') === context.contextName) { + scriptNode.getAttribute('data-requirecontext') === context.contextName) { scriptNode.parentNode.removeChild(scriptNode); return true; } @@ -456,8 +457,8 @@ var requirejs, require, define; // loading of a loader plugin. But for now, fixes the // common uses. Details in #1131 normalizedName = name.indexOf('!') === -1 ? - normalize(name, parentName, applyMap) : - name; + normalize(name, parentName, applyMap) : + name; } } else { //A regular module. @@ -479,8 +480,8 @@ var requirejs, require, define; //normalization, stamp it with a unique ID so two matching relative //ids that may conflict can be separate. suffix = prefix && !pluginModule && !isNormalized ? - '_unnormalized' + (unnormalizedCounter += 1) : - ''; + '_unnormalized' + (unnormalizedCounter += 1) : + ''; return { prefix: prefix, @@ -491,8 +492,8 @@ var requirejs, require, define; originalName: originalName, isDefine: isDefine, id: (prefix ? - prefix + '!' + normalizedName : - normalizedName) + suffix + prefix + '!' + normalizedName : + normalizedName) + suffix }; } @@ -512,7 +513,7 @@ var requirejs, require, define; mod = getOwn(registry, id); if (hasProp(defined, id) && - (!mod || mod.defineEmitComplete)) { + (!mod || mod.defineEmitComplete)) { if (name === 'defined') { fn(defined[id]); } @@ -974,8 +975,8 @@ var requirejs, require, define; //prefix and name should already be normalized, no need //for applying map config again either. normalizedMap = makeModuleMap(map.prefix + '!' + name, - this.map.parentMap, - true); + this.map.parentMap, + true); on(normalizedMap, 'defined', bind(this, function (value) { this.map.normalizedMap = normalizedMap; @@ -1067,10 +1068,10 @@ var requirejs, require, define; req.exec(text); } catch (e) { return onError(makeError('fromtexteval', - 'fromText eval for ' + id + - ' failed: ' + e, - e, - [id])); + 'fromText eval for ' + id + + ' failed: ' + e, + e, + [id])); } if (hasInteractive) { @@ -1117,9 +1118,9 @@ var requirejs, require, define; //Dependency needs to be converted to a depMap //and wired up to this module. depMap = makeModuleMap(depMap, - (this.map.isDefine ? this.map : this.map.parentMap), - false, - !this.skipMap); + (this.map.isDefine ? this.map : this.map.parentMap), + false, + !this.skipMap); this.depMaps[i] = depMap; handler = getOwn(handlers, depMap.id); @@ -1272,7 +1273,6 @@ var requirejs, require, define; defQueueMap: {}, Module: Module, makeModuleMap: makeModuleMap, - nextTick: req.nextTick, onError: onError, /** @@ -1363,8 +1363,8 @@ var requirejs, require, define; //envs have different conventions: some use a module name, //some use a file name. config.pkgs[name] = pkgObj.name + '/' + (pkgObj.main || 'main') - .replace(currDirRegExp, '') - .replace(jsSuffixRegExp, ''); + .replace(currDirRegExp, '') + .replace(jsSuffixRegExp, ''); }); } @@ -1434,10 +1434,10 @@ var requirejs, require, define; if (!hasProp(defined, id)) { return onError(makeError('notloaded', 'Module name "' + - id + - '" has not been loaded yet for context: ' + - contextName + - (relMap ? '' : '. Use require([])'))); + id + + '" has not been loaded yet for context: ' + + contextName + + (relMap ? '' : '. Use require([])'))); } return defined[id]; } @@ -1445,25 +1445,18 @@ var requirejs, require, define; //Grab defines waiting in the global queue. intakeDefines(); - //Mark all the dependencies as needing to be loaded. - context.nextTick(function () { - //Some defines could have been added since the - //require call, collect them. - intakeDefines(); - - requireMod = getModule(makeModuleMap(null, relMap)); + requireMod = getModule(makeModuleMap(null, relMap)); - //Store if map config should be applied to this require - //call for dependencies. - requireMod.skipMap = options.skipMap; + //Store if map config should be applied to this require + //call for dependencies. + requireMod.skipMap = options.skipMap; - requireMod.init(deps, callback, errback, { - enabled: true - }); - - checkLoaded(); + requireMod.init(deps, callback, errback, { + enabled: true }); + checkLoaded(); + return localRequire; } @@ -1489,7 +1482,7 @@ var requirejs, require, define; } return context.nameToUrl(normalize(moduleNamePlusExt, - relMap && relMap.id, true), ext, true); + relMap && relMap.id, true), ext, true); }, defined: function (id) { @@ -1601,9 +1594,9 @@ var requirejs, require, define; return; } else { return onError(makeError('nodefine', - 'No define call for ' + moduleName, - null, - [moduleName])); + 'No define call for ' + moduleName, + null, + [moduleName])); } } else { //A script that does not call define(), so just simulate @@ -1676,7 +1669,7 @@ var requirejs, require, define; } return config.urlArgs && !/^blob\:/.test(url) ? - url + config.urlArgs(moduleName, url) : url; + url + config.urlArgs(moduleName, url) : url; }, //Delegates to req.load. Broken out as a separate function to @@ -1707,7 +1700,7 @@ var requirejs, require, define; //all old browsers will be supported, but this one was easy enough //to support and still makes sense. if (evt.type === 'load' || - (readyRegExp.test((evt.currentTarget || evt.srcElement).readyState))) { + (readyRegExp.test((evt.currentTarget || evt.srcElement).readyState))) { //Reset interactive script so a script node is not held onto for //to long. interactiveScript = null; @@ -1736,9 +1729,9 @@ var requirejs, require, define; } }); return onError(makeError('scripterror', 'Script error for "' + data.id + - (parents.length ? - '", needed by: ' + parents.join(', ') : - '"'), evt, [data.id])); + (parents.length ? + '", needed by: ' + parents.join(', ') : + '"'), evt, [data.id])); } } }; @@ -1805,16 +1798,6 @@ var requirejs, require, define; return req(config); }; - /** - * Execute something after the current tick - * of the event loop. Override for other envs - * that have a better solution than setTimeout. - * @param {Function} fn function to execute later. - */ - req.nextTick = typeof setTimeout !== 'undefined' ? function (fn) { - setTimeout(fn, 4); - } : function (fn) { fn(); }; - /** * Export require as a global, but only if it does not already exist. */ @@ -1874,8 +1857,8 @@ var requirejs, require, define; */ req.createNode = function (config, moduleName, url) { var node = config.xhtml ? - document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') : - document.createElement('script'); + document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') : + document.createElement('script'); node.type = config.scriptType || 'text/javascript'; node.charset = 'utf-8'; node.async = true; @@ -1910,15 +1893,15 @@ var requirejs, require, define; //UNFORTUNATELY Opera implements attachEvent but does not follow the script //script execution mode. if (node.attachEvent && - //Check if node.attachEvent is artificially added by custom script or - //natively supported by browser - //read https://github.com/requirejs/requirejs/issues/187 - //if we can NOT find [native code] then it must NOT natively supported. - //in IE8, node.attachEvent does not have toString() - //Note the test for "[native code" with no closing brace, see: - //https://github.com/requirejs/requirejs/issues/273 - !(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) && - !isOpera) { + //Check if node.attachEvent is artificially added by custom script or + //natively supported by browser + //read https://github.com/requirejs/requirejs/issues/187 + //if we can NOT find [native code] then it must NOT natively supported. + //in IE8, node.attachEvent does not have toString() + //Note the test for "[native code" with no closing brace, see: + //https://github.com/requirejs/requirejs/issues/273 + !(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) && + !isOpera) { //Probably IE. IE (at least 6-8) do not fire //script onload right after executing the script, so //we cannot tie the anonymous define call to a name. @@ -1982,10 +1965,10 @@ var requirejs, require, define; context.completeLoad(moduleName); } catch (e) { context.onError(makeError('importscripts', - 'importScripts failed for ' + - moduleName + ' at ' + url, - e, - [moduleName])); + 'importScripts failed for ' + + moduleName + ' at ' + url, + e, + [moduleName])); } } };