Update vendors.

Former-commit-id: b239f365c9d8e012bf20525167e6d1a412ce828e
This commit is contained in:
John-David Dalton
2012-08-12 21:57:09 -07:00
parent be4f81f584
commit 23ff403529
9 changed files with 238 additions and 123 deletions

View File

@@ -1290,8 +1290,8 @@
_ensureElement: function() { _ensureElement: function() {
if (!this.el) { if (!this.el) {
var attrs = _.extend({}, getValue(this, 'attributes')); var attrs = _.extend({}, getValue(this, 'attributes'));
if (this.id) attrs.id = this.id; if (this.id) attrs.id = getValue(this, 'id');
if (this.className) attrs['class'] = this.className; if (this.className) attrs['class'] = getValue(this, 'className');
this.setElement(this.make(getValue(this, 'tagName'), attrs), false); this.setElement(this.make(getValue(this, 'tagName'), attrs), false);
} else { } else {
this.setElement(this.el, false); this.setElement(this.el, false);

View File

@@ -135,6 +135,20 @@ $(document).ready(function() {
ok(!view.el); ok(!view.el);
}); });
test("View: with className and id functions", 2, function() {
var View = Backbone.View.extend({
className: function() {
return 'className';
},
id: function() {
return 'id';
}
});
var view = new View();
strictEqual(view.el.className, 'className');
strictEqual(view.el.id, 'id');
});
test("View: with attributes", 2, function() { test("View: with attributes", 2, function() {
var view = new Backbone.View({attributes : {'class': 'one', id: 'two'}}); var view = new Backbone.View({attributes : {'class': 'one', id: 'two'}});
equal(view.el.className, 'one'); equal(view.el.className, 'one');

View File

@@ -1,4 +1,4 @@
# Benchmark.js <sup>v1.0.0-pre</sup> # Benchmark.js <sup>v1.0.0</sup>
A [robust](http://calendar.perfplanet.com/2010/bulletproof-javascript-benchmarks/ "Bulletproof JavaScript benchmarks") benchmarking library that works on nearly all JavaScript platforms<sup><a name="fnref1" href="#fn1">1</a></sup>, supports high-resolution timers, and returns statistically significant results. As seen on [jsPerf](http://jsperf.com/). A [robust](http://calendar.perfplanet.com/2010/bulletproof-javascript-benchmarks/ "Bulletproof JavaScript benchmarks") benchmarking library that works on nearly all JavaScript platforms<sup><a name="fnref1" href="#fn1">1</a></sup>, supports high-resolution timers, and returns statistically significant results. As seen on [jsPerf](http://jsperf.com/).
@@ -12,6 +12,10 @@ The documentation for Benchmark.js can be viewed here: <http://benchmarkjs.com/d
For a list of upcoming features, check out our [roadmap](https://github.com/bestiejs/benchmark.js/wiki/Roadmap). For a list of upcoming features, check out our [roadmap](https://github.com/bestiejs/benchmark.js/wiki/Roadmap).
## Support
Benchmark.js has been tested in at least Adobe AIR 2.6, Chrome 5-21, Firefox 1.5-13, IE 6-9, Opera 9.25-12.01, Safari 3-6, Node.js 0.4.8-0.8.6, Narwhal 0.3.2, RingoJS 0.8, and Rhino 1.7RC3.
## Installation and usage ## Installation and usage
In a browser or Adobe AIR: In a browser or Adobe AIR:
@@ -114,11 +118,6 @@ suite.add('RegExp#test', function() {
// > Fastest is String#indexOf // > Fastest is String#indexOf
~~~ ~~~
## Footnotes
1. Benchmark.js has been tested in at least Adobe AIR 2.6, Chrome 5-15, Firefox 1.5-8, IE 6-10, Opera 9.25-11.52, Safari 2-5.1.1, Node.js 0.4.8-0.6.1, Narwhal 0.3.2, RingoJS 0.7-0.8, and Rhino 1.7RC3.
<a name="fn1" title="Jump back to footnote 1 in the text." href="#fnref1">&#8617;</a>
## Authors ## Authors
* [Mathias Bynens](http://mathiasbynens.be/) * [Mathias Bynens](http://mathiasbynens.be/)

View File

@@ -1,5 +1,5 @@
/*! /*!
* Benchmark.js v1.0.0-pre <http://benchmarkjs.com/> * Benchmark.js v1.0.0 <http://benchmarkjs.com/>
* Copyright 2010-2012 Mathias Bynens <http://mths.be/> * Copyright 2010-2012 Mathias Bynens <http://mths.be/>
* Based on JSLitmus.js, copyright Robert Kieffer <http://broofa.com/> * Based on JSLitmus.js, copyright Robert Kieffer <http://broofa.com/>
* Modified by John-David Dalton <http://allyoucanleet.com/> * Modified by John-David Dalton <http://allyoucanleet.com/>
@@ -3218,7 +3218,7 @@
* @memberOf Benchmark * @memberOf Benchmark
* @type String * @type String
*/ */
'version': '1.0.0-pre', 'version': '1.0.0',
// an object of environment/feature detection flags // an object of environment/feature detection flags
'support': support, 'support': support,

View File

@@ -196,7 +196,7 @@ class Entry {
* @returns {Array} The entry `param` data. * @returns {Array} The entry `param` data.
*/ */
public function getParams( $index = null ) { public function getParams( $index = null ) {
preg_match_all('#\*\s*@param\s+\{([^}]+)\}\s+(\[[^]]+\]|[$\w]+)\s+([\s\S]*?)(?=\*\s\@[a-z]|\*/)#i', $this->entry, $result); preg_match_all('#\*\s*@param\s+\{([^}]+)\}\s+(\[.+\]|[$\w]+)\s+([\s\S]*?)(?=\*\s\@[a-z]|\*/)#i', $this->entry, $result);
if (count($result = array_filter(array_slice($result, 1)))) { if (count($result = array_filter(array_slice($result, 1)))) {
// repurpose array // repurpose array
foreach ($result as $param) { foreach ($result as $param) {

View File

@@ -208,6 +208,7 @@ class Generator {
$openTag = "\n<!-- div -->\n"; $openTag = "\n<!-- div -->\n";
$closeTag = "\n<!-- /div -->\n"; $closeTag = "\n<!-- /div -->\n";
$result = array('# ' . $this->options['title']); $result = array('# ' . $this->options['title']);
$toc = 'toc';
// initialize $api array // initialize $api array
foreach ($this->entries as $entry) { foreach ($this->entries as $entry) {
@@ -304,10 +305,15 @@ class Generator {
$compiling = $compiling ? ($result[] = $closeTag) : true; $compiling = $compiling ? ($result[] = $closeTag) : true;
// assign TOC hash
if (count($result) == 2) {
$toc = $member;
}
// add root entry // add root entry
array_push( array_push(
$result, $result,
$openTag, '## ' . (count($result) == 2 ? '<a id="toc"></a>' : '') . '`' . $member . '`', $openTag, '## ' . (count($result) == 2 ? '<a id="' . $toc . '"></a>' : '') . '`' . $member . '`',
Generator::interpolate('* [`' . $member . '`](##{hash})', $entry) Generator::interpolate('* [`' . $member . '`](##{hash})', $entry)
); );
@@ -401,7 +407,7 @@ class Generator {
} }
// close tags add TOC link reference // close tags add TOC link reference
array_push($result, $closeTag, $closeTag, '', ' [1]: #toc "Jump back to the TOC."'); array_push($result, $closeTag, $closeTag, '', ' [1]: #' . $toc . ' "Jump back to the TOC."');
// cleanup whitespace // cleanup whitespace
return trim(preg_replace('/ +\n/', "\n", join($result, "\n"))); return trim(preg_replace('/ +\n/', "\n", join($result, "\n")));

View File

@@ -1,4 +1,4 @@
# Platform.js <sup>v1.0.0-pre</sup> # Platform.js <sup>v1.0.0</sup>
A platform detection library that works on nearly all JavaScript platforms<sup><a name="fnref1" href="#fn1">1</a></sup>. A platform detection library that works on nearly all JavaScript platforms<sup><a name="fnref1" href="#fn1">1</a></sup>.
@@ -16,6 +16,10 @@ The documentation for Platform.js can be viewed here: [/doc/README.md](https://g
For a list of upcoming features, check out our [roadmap](https://github.com/bestiejs/platform.js/wiki/Roadmap). For a list of upcoming features, check out our [roadmap](https://github.com/bestiejs/platform.js/wiki/Roadmap).
## Support
Platform.js has been tested in at least Chrome 5-21, Firefox 1.5-13, IE 6-9, Opera 9.25-12.01, Safari 3-6, Node.js 0.4.8-0.8.6, Narwhal 0.3.2, RingoJS 0.8, and Rhino 1.7RC3.
## Installation and usage ## Installation and usage
In a browser or Adobe AIR: In a browser or Adobe AIR:
@@ -83,11 +87,6 @@ info.os; // 'Mac OS X 10.7.2'
info.description; // 'Opera 11.52 (identifying as Firefox 4.0) on Mac OS X 10.7.2' info.description; // 'Opera 11.52 (identifying as Firefox 4.0) on Mac OS X 10.7.2'
~~~ ~~~
## Footnotes
1. Platform.js has been tested in at least Adobe AIR 2.6, Chrome 5-15, Firefox 1.5-8, IE 6-10, Opera 9.25-11.52, Safari 2-5.1.1, Node.js 0.4.8-0.6.1, Narwhal 0.3.2, RingoJS 0.7-0.8, and Rhino 1.7RC3.
<a name="fn1" title="Jump back to footnote 1 in the text." href="#fnref1">&#8617;</a>
## Author ## Author
* [John-David Dalton](http://allyoucanleet.com/) * [John-David Dalton](http://allyoucanleet.com/)

View File

@@ -1,5 +1,5 @@
/*! /*!
* Platform.js v1.0.0-pre <http://mths.be/platform> * Platform.js v1.0.0 <http://mths.be/platform>
* Copyright 2010-2012 John-David Dalton <http://allyoucanleet.com/> * Copyright 2010-2012 John-David Dalton <http://allyoucanleet.com/>
* Available under MIT license <http://mths.be/mit> * Available under MIT license <http://mths.be/mit>
*/ */
@@ -297,7 +297,7 @@
'Opera Mini', 'Opera Mini',
'Opera', 'Opera',
'Chrome', 'Chrome',
{ 'label': 'Chrome Mobile', 'pattern': 'CrMo' }, { 'label': 'Chrome Mobile', 'pattern': '(?:CriOS|CrMo)' },
{ 'label': 'Firefox', 'pattern': '(?:Firefox|Minefield)' }, { 'label': 'Firefox', 'pattern': '(?:Firefox|Minefield)' },
{ 'label': 'IE', 'pattern': 'MSIE' }, { 'label': 'IE', 'pattern': 'MSIE' },
'Safari' 'Safari'
@@ -512,12 +512,11 @@
/*------------------------------------------------------------------------*/ /*------------------------------------------------------------------------*/
/** /**
* Return platform description when the platform object is coerced to a string. * Returns `platform.description` when the platform object is coerced to a string.
* *
* @name toString * @name toString
* @memberOf platform * @memberOf platform
* @type Function * @returns {String} Returns `platform.description` if available, else an empty string.
* @returns {String} The platform description.
*/ */
function toStringPlatform() { function toStringPlatform() {
return this.description || ''; return this.description || '';
@@ -573,7 +572,7 @@
// detect non-Opera versions (order is important) // detect non-Opera versions (order is important)
if (!version) { if (!version) {
version = getVersion([ version = getVersion([
'(?:Cloud9|CrMo|Opera ?Mini|Raven|Silk(?!/[\\d.]+$))', '(?:Cloud9|CriOS|CrMo|Opera ?Mini|Raven|Silk(?!/[\\d.]+$))',
'Version', 'Version',
qualify(name), qualify(name),
'(?:Firefox|Minefield|NetFront)' '(?:Firefox|Minefield|NetFront)'
@@ -708,7 +707,7 @@
)) ))
) && !reOpera.test(data = parse.call(forOwn, ua.replace(reOpera, '') + ';')) && data.name) { ) && !reOpera.test(data = parse.call(forOwn, ua.replace(reOpera, '') + ';')) && data.name) {
// when "indentifying" the UA contains both Opera and the other browser's name // when "indentifying", the UA contains both Opera and the other browser's name
data = 'ing as ' + data.name + ((data = data.version) ? ' ' + data : ''); data = 'ing as ' + data.name + ((data = data.version) ? ' ' + data : '');
if (reOpera.test(name)) { if (reOpera.test(name)) {
if (/IE/.test(data) && os == 'Mac OS') { if (/IE/.test(data) && os == 'Mac OS') {
@@ -716,7 +715,7 @@
} }
data = 'identify' + data; data = 'identify' + data;
} }
// when "masking" the UA contains only the other browser's name // when "masking", the UA contains only the other browser's name
else { else {
data = 'mask' + data; data = 'mask' + data;
if (operaClass) { if (operaClass) {
@@ -760,7 +759,7 @@
data = (data = data[0], data < 400 ? 1 : data < 500 ? 2 : data < 526 ? 3 : data < 533 ? 4 : data < 534 ? '4+' : data < 535 ? 5 : '5'); data = (data = data[0], data < 400 ? 1 : data < 500 ? 2 : data < 526 ? 3 : data < 533 ? 4 : data < 534 ? '4+' : data < 535 ? 5 : '5');
} else { } else {
layout[1] = 'like Chrome'; layout[1] = 'like Chrome';
data = data[1] || (data = data[0], data < 530 ? 1 : data < 532 ? 2 : data < 532.05 ? 3 : data < 533 ? 4 : data < 534.03 ? 5 : data < 534.07 ? 6 : data < 534.10 ? 7 : data < 534.13 ? 8 : data < 534.16 ? 9 : data < 534.24 ? 10 : data < 534.30 ? 11 : data < 535.01 ? 12 : data < 535.02 ? '13+' : data < 535.07 ? 15 : data < 535.11 ? 16 : data < 535.19 ? 17 : data < 535.21 ? 18 : '19'); data = data[1] || (data = data[0], data < 530 ? 1 : data < 532 ? 2 : data < 532.05 ? 3 : data < 533 ? 4 : data < 534.03 ? 5 : data < 534.07 ? 6 : data < 534.10 ? 7 : data < 534.13 ? 8 : data < 534.16 ? 9 : data < 534.24 ? 10 : data < 534.30 ? 11 : data < 535.01 ? 12 : data < 535.02 ? '13+' : data < 535.07 ? 15 : data < 535.11 ? 16 : data < 535.19 ? 17 : data < 536.05 ? 18 : data < 536.10 ? 19 : data < 537.01 ? 20 : '21');
} }
// add the postfix of ".x" or "+" for approximate versions // add the postfix of ".x" or "+" for approximate versions
layout[1] += ' ' + (data += typeof data == 'number' ? '.x' : /[.+]/.test(data) ? '' : '+'); layout[1] += ' ' + (data += typeof data == 'number' ? '.x' : /[.+]/.test(data) ? '' : '+');
@@ -769,6 +768,30 @@
version = data; version = data;
} }
} }
// detect Opera desktop modes
if (name == 'Opera' && (data = /(?:zbov|zvav)$/.exec(os))) {
name += ' ';
description.unshift('desktop mode');
if (data == 'zvav') {
name += 'Mini';
version = null;
} else {
name += 'Mobile';
}
}
// detect Chrome desktop mode
else if (name == 'Safari' && /Chrome/.exec(layout[1])) {
description.unshift('desktop mode');
name = 'Chrome Mobile';
version = null;
if (/Mac OS X/.test(os)) {
manufacturer = 'Apple';
os = 'iOS 4.3+';
} else {
os = null;
}
}
// strip incorrect OS versions // strip incorrect OS versions
if (version && version.indexOf(data = /[\d.]+$/.exec(os)) == 0 && if (version && version.indexOf(data = /[\d.]+$/.exec(os)) == 0 &&
ua.indexOf('/' + data + '-') > -1) { ua.indexOf('/' + data + '-') > -1) {
@@ -793,9 +816,25 @@
if (product) { if (product) {
description.push((/^on /.test(description[description.length -1]) ? '' : 'on ') + product); description.push((/^on /.test(description[description.length -1]) ? '' : 'on ') + product);
} }
// parse OS into an object
if (os) {
data = / ([\d.+]+)$/.exec(os);
os = {
'architecture': 32,
'family': data ? os.replace(data[0], '') : os,
'version': data ? data[1] : null,
'toString': function() {
var version = this.version;
return this.family + (version ? ' ' + version : '') + (this.architecture == 64 ? ' 64-bit' : '');
}
};
}
// add browser/OS architecture // add browser/OS architecture
if ((data = /\b(?:AMD|IA|Win|WOW|x86_|x)64\b/i).test(arch) && !/\bi686\b/i.test(arch)) { if ((data = / (?:AMD|IA|Win|WOW|x86_|x)64\b/i.exec(arch)) && !/\bi686\b/i.test(arch)) {
os = os && os + (data.test(os) ? '' : ' 64-bit'); if (os) {
os.architecture = 64;
os.family = os.family.replace(data, '');
}
if (name && (/WOW64/i.test(ua) || if (name && (/WOW64/i.test(ua) ||
(useFeatures && /\w(?:86|32)$/.test(nav.cpuClass || nav.platform)))) { (useFeatures && /\w(?:86|32)$/.test(nav.cpuClass || nav.platform)))) {
description.unshift('32-bit'); description.unshift('32-bit');
@@ -834,11 +873,46 @@
* The name of the operating system. * The name of the operating system.
* *
* @memberOf platform * @memberOf platform
* @type String|Null * @type Object
*/ */
'os': os && (name && 'os': os
!(os == os.split(' ')[0] && (os == name.split(' ')[0] || product)) && ? (name &&
description.push(product ? '(' + os + ')' : 'on ' + os), os), !(os == String(os).split(' ')[0] && (os == name.split(' ')[0] || product)) &&
description.push(product ? '(' + os + ')' : 'on ' + os), os)
: {
/**
* The CPU architecture the OS is built for.
*
* @memberOf platform.os
* @type String|Null
*/
'architecture': null,
/**
* The family of the OS.
*
* @memberOf platform.os
* @type String|Null
*/
'family': null,
/**
* The version of the OS.
*
* @memberOf platform.os
* @type String|Null
*/
'version': null,
/**
* Returns the OS string.
*
* @memberOf platform.os
* @returns {String} The OS string.
*/
'toString': function() { return 'null'; }
},
/** /**
* The platform description. * The platform description.

View File

@@ -1,21 +1,25 @@
/** vim: et:ts=4:sw=4:sts=4 /** vim: et:ts=4:sw=4:sts=4
* @license RequireJS 2.0.4 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved. * @license RequireJS 2.0.5 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license. * Available via the MIT or new BSD license.
* see: http://github.com/jrburke/requirejs for details * see: http://github.com/jrburke/requirejs for details
*/ */
/*jslint regexp: true, nomen: true */ //Not using strict: uneven strict support in browsers, #392, and causes
//problems with requirejs.exec()/transpiler plugins that may not be strict.
/*jslint regexp: true, nomen: true, sloppy: true */
/*global window, navigator, document, importScripts, jQuery, setTimeout, opera */ /*global window, navigator, document, importScripts, jQuery, setTimeout, opera */
var requirejs, require, define; var requirejs, require, define;
(function (global) { (function (global) {
'use strict'; var req, s, head, baseElement, dataMain, src,
interactiveScript, currentlyAddingScript, mainScript, subPath,
var version = '2.0.4', version = '2.0.5',
commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg, commentRegExp = /(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,
cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g, cjsRequireRegExp = /[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,
jsSuffixRegExp = /\.js$/, jsSuffixRegExp = /\.js$/,
currDirRegExp = /^\.\//, currDirRegExp = /^\.\//,
ostring = Object.prototype.toString, op = Object.prototype,
ostring = op.toString,
hasOwn = op.hasOwnProperty,
ap = Array.prototype, ap = Array.prototype,
aps = ap.slice, aps = ap.slice,
apsp = ap.splice, apsp = ap.splice,
@@ -33,9 +37,7 @@ var requirejs, require, define;
contexts = {}, contexts = {},
cfg = {}, cfg = {},
globalDefQueue = [], globalDefQueue = [],
useInteractive = false, useInteractive = false;
req, s, head, baseElement, dataMain, src,
interactiveScript, currentlyAddingScript, mainScript, subPath;
function isFunction(it) { function isFunction(it) {
return ostring.call(it) === '[object Function]'; return ostring.call(it) === '[object Function]';
@@ -76,7 +78,7 @@ var requirejs, require, define;
} }
function hasProp(obj, prop) { function hasProp(obj, prop) {
return obj.hasOwnProperty(prop); return hasOwn.call(obj, prop);
} }
/** /**
@@ -152,7 +154,7 @@ var requirejs, require, define;
//look up paths relative to the moduleName //look up paths relative to the moduleName
var args = aps.call(arguments, 0), lastArg; var args = aps.call(arguments, 0), lastArg;
if (enableBuildCallback && if (enableBuildCallback &&
isFunction((lastArg = args[args.length - 1]))) { isFunction((lastArg = args[args.length - 1]))) {
lastArg.__requireJsBuild = true; lastArg.__requireJsBuild = true;
} }
args.push(relMap); args.push(relMap);
@@ -169,14 +171,14 @@ var requirejs, require, define;
], function (item) { ], function (item) {
var prop = item[1] || item[0]; var prop = item[1] || item[0];
req[item[0]] = context ? makeContextModuleFunc(context[prop], relMap) : req[item[0]] = context ? makeContextModuleFunc(context[prop], relMap) :
//If no context, then use default context. Reference from //If no context, then use default context. Reference from
//contexts instead of early binding to default context, so //contexts instead of early binding to default context, so
//that during builds, the latest instance of the default //that during builds, the latest instance of the default
//context with its config gets used. //context with its config gets used.
function () { function () {
var ctx = contexts[defContextName]; var ctx = contexts[defContextName];
return ctx[prop].apply(ctx, arguments); return ctx[prop].apply(ctx, arguments);
}; };
}); });
} }
@@ -221,7 +223,9 @@ var requirejs, require, define;
} }
function newContext(contextName) { function newContext(contextName) {
var config = { var inCheckLoaded, Module, context, handlers,
checkLoadedTimeoutId,
config = {
waitSeconds: 7, waitSeconds: 7,
baseUrl: './', baseUrl: './',
paths: {}, paths: {},
@@ -239,9 +243,7 @@ var requirejs, require, define;
//should be executed, by the order they //should be executed, by the order they
//load. Important for consistent cycle resolution //load. Important for consistent cycle resolution
//behavior. //behavior.
waitAry = [], waitAry = [];
inCheckLoaded, Module, context, handlers,
checkLoadedTimeoutId;
/** /**
* Trims the . and .. from an array of path segments. * Trims the . and .. from an array of path segments.
@@ -254,7 +256,7 @@ var requirejs, require, define;
*/ */
function trimDots(ary) { function trimDots(ary) {
var i, part; var i, part;
for (i = 0; ary[i]; i+= 1) { for (i = 0; ary[i]; i += 1) {
part = ary[i]; part = ary[i];
if (part === '.') { if (part === '.') {
ary.splice(i, 1); ary.splice(i, 1);
@@ -287,12 +289,12 @@ var requirejs, require, define;
* @returns {String} normalized name * @returns {String} normalized name
*/ */
function normalize(name, baseName, applyMap) { function normalize(name, baseName, applyMap) {
var baseParts = baseName && baseName.split('/'), var pkgName, pkgConfig, mapValue, nameParts, i, j, nameSegment,
foundMap, foundI, foundStarMap, starI,
baseParts = baseName && baseName.split('/'),
normalizedBaseParts = baseParts, normalizedBaseParts = baseParts,
map = config.map, map = config.map,
starMap = map && map['*'], starMap = map && map['*'];
pkgName, pkgConfig, mapValue, nameParts, i, j, nameSegment,
foundMap;
//Adjust any relative paths. //Adjust any relative paths.
if (name && name.charAt(0) === '.') { if (name && name.charAt(0) === '.') {
@@ -343,28 +345,41 @@ var requirejs, require, define;
for (j = baseParts.length; j > 0; j -= 1) { for (j = baseParts.length; j > 0; j -= 1) {
mapValue = map[baseParts.slice(0, j).join('/')]; mapValue = map[baseParts.slice(0, j).join('/')];
//baseName segment has config, find if it has one for //baseName segment has config, find if it has one for
//this name. //this name.
if (mapValue) { if (mapValue) {
mapValue = mapValue[nameSegment]; mapValue = mapValue[nameSegment];
if (mapValue) { if (mapValue) {
//Match, update name to the new value. //Match, update name to the new value.
foundMap = mapValue; foundMap = mapValue;
foundI = i;
break; break;
} }
} }
} }
} }
if (!foundMap && starMap && starMap[nameSegment]) {
foundMap = starMap[nameSegment];
}
if (foundMap) { if (foundMap) {
nameParts.splice(0, i, foundMap);
name = nameParts.join('/');
break; break;
} }
//Check for a star map match, but just hold on to it,
//if there is a shorter segment match later in a matching
//config, then favor over this star map.
if (!foundStarMap && starMap && starMap[nameSegment]) {
foundStarMap = starMap[nameSegment];
starI = i;
}
}
if (!foundMap && foundStarMap) {
foundMap = foundStarMap;
foundI = starI;
}
if (foundMap) {
nameParts.splice(0, foundI, foundMap);
name = nameParts.join('/');
} }
} }
@@ -375,7 +390,7 @@ var requirejs, require, define;
if (isBrowser) { if (isBrowser) {
each(scripts(), function (scriptNode) { each(scripts(), function (scriptNode) {
if (scriptNode.getAttribute('data-requiremodule') === name && if (scriptNode.getAttribute('data-requiremodule') === name &&
scriptNode.getAttribute('data-requirecontext') === context.contextName) { scriptNode.getAttribute('data-requirecontext') === context.contextName) {
scriptNode.parentNode.removeChild(scriptNode); scriptNode.parentNode.removeChild(scriptNode);
return true; return true;
} }
@@ -412,13 +427,13 @@ var requirejs, require, define;
* @returns {Object} * @returns {Object}
*/ */
function makeModuleMap(name, parentModuleMap, isNormalized, applyMap) { function makeModuleMap(name, parentModuleMap, isNormalized, applyMap) {
var index = name ? name.indexOf('!') : -1, var url, pluginModule, suffix,
index = name ? name.indexOf('!') : -1,
prefix = null, prefix = null,
parentName = parentModuleMap ? parentModuleMap.name : null, parentName = parentModuleMap ? parentModuleMap.name : null,
originalName = name, originalName = name,
isDefine = true, isDefine = true,
normalizedName = '', normalizedName = '';
url, pluginModule, suffix;
//If no name, then it means it is a require call, generate an //If no name, then it means it is a require call, generate an
//internal name. //internal name.
@@ -471,8 +486,8 @@ var requirejs, require, define;
originalName: originalName, originalName: originalName,
isDefine: isDefine, isDefine: isDefine,
id: (prefix ? id: (prefix ?
prefix + '!' + normalizedName : prefix + '!' + normalizedName :
normalizedName) + suffix normalizedName) + suffix
}; };
} }
@@ -492,7 +507,7 @@ var requirejs, require, define;
mod = registry[id]; mod = registry[id];
if (hasProp(defined, id) && if (hasProp(defined, id) &&
(!mod || mod.defineEmitComplete)) { (!mod || mod.defineEmitComplete)) {
if (name === 'defined') { if (name === 'defined') {
fn(defined[id]); fn(defined[id]);
} }
@@ -659,7 +674,7 @@ var requirejs, require, define;
traced[id] = mod; traced[id] = mod;
each(depArray, function(depMap) { each(depArray, function (depMap) {
var depId = depMap.id, var depId = depMap.id,
depMod = registry[depId], depMod = registry[depId],
value; value;
@@ -699,13 +714,13 @@ var requirejs, require, define;
} }
function checkLoaded() { function checkLoaded() {
var waitInterval = config.waitSeconds * 1000, var map, modId, err, usingPathFallback,
waitInterval = config.waitSeconds * 1000,
//It is possible to disable the wait interval by using waitSeconds of 0. //It is possible to disable the wait interval by using waitSeconds of 0.
expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(), expired = waitInterval && (context.startTime + waitInterval) < new Date().getTime(),
noLoads = [], noLoads = [],
stillLoading = false, stillLoading = false,
needCycleCheck = true, needCycleCheck = true;
map, modId, err, usingPathFallback;
//Do not bother if this call was a result of a cycle break. //Do not bother if this call was a result of a cycle break.
if (inCheckLoaded) { if (inCheckLoaded) {
@@ -819,7 +834,7 @@ var requirejs, require, define;
}; };
Module.prototype = { Module.prototype = {
init: function(depMaps, factory, errback, options) { init: function (depMaps, factory, errback, options) {
options = options || {}; options = options || {};
//Do not do more inits if already done. Can happen if there //Do not do more inits if already done. Can happen if there
@@ -916,7 +931,7 @@ var requirejs, require, define;
} }
}, },
load: function() { load: function () {
var url = this.map.url; var url = this.map.url;
//Regular dependency. //Regular dependency.
@@ -937,11 +952,11 @@ var requirejs, require, define;
return; return;
} }
var id = this.map.id, var err, cjsModule,
id = this.map.id,
depExports = this.depExports, depExports = this.depExports,
exports = this.exports, exports = this.exports,
factory = this.factory, factory = this.factory;
err, cjsModule;
if (!this.inited) { if (!this.inited) {
this.fetch(); this.fetch();
@@ -974,9 +989,9 @@ var requirejs, require, define;
//favor a non-undefined return value over exports use. //favor a non-undefined return value over exports use.
cjsModule = this.module; cjsModule = this.module;
if (cjsModule && if (cjsModule &&
cjsModule.exports !== undefined && cjsModule.exports !== undefined &&
//Make sure it is not already the exports value //Make sure it is not already the exports value
cjsModule.exports !== this.exports) { cjsModule.exports !== this.exports) {
exports = cjsModule.exports; exports = cjsModule.exports;
} else if (exports === undefined && this.usingExports) { } else if (exports === undefined && this.usingExports) {
//exports already set the defined value. //exports already set the defined value.
@@ -1032,15 +1047,15 @@ var requirejs, require, define;
} }
}, },
callPlugin: function() { callPlugin: function () {
var map = this.map, var map = this.map,
id = map.id, id = map.id,
pluginMap = makeModuleMap(map.prefix, null, false, true); pluginMap = makeModuleMap(map.prefix, null, false, true);
on(pluginMap, 'defined', bind(this, function (plugin) { on(pluginMap, 'defined', bind(this, function (plugin) {
var name = this.map.name, var load, normalizedMap, normalizedMod,
parentName = this.map.parentMap ? this.map.parentMap.name : null, name = this.map.name,
load, normalizedMap, normalizedMod; parentName = this.map.parentMap ? this.map.parentMap.name : null;
//If current map is not normalized, wait for that //If current map is not normalized, wait for that
//normalized name to load instead of continuing. //normalized name to load instead of continuing.
@@ -1057,12 +1072,12 @@ var requirejs, require, define;
false, false,
true); true);
on(normalizedMap, on(normalizedMap,
'defined', bind(this, function (value) { 'defined', bind(this, function (value) {
this.init([], function () { return value; }, null, { this.init([], function () { return value; }, null, {
enabled: true, enabled: true,
ignore: true ignore: true
}); });
})); }));
normalizedMod = registry[normalizedMap.id]; normalizedMod = registry[normalizedMap.id];
if (normalizedMod) { if (normalizedMod) {
if (this.events.error) { if (this.events.error) {
@@ -1127,9 +1142,9 @@ var requirejs, require, define;
//Use parentName here since the plugin's name is not reliable, //Use parentName here since the plugin's name is not reliable,
//could be some weird string with no path that actually wants to //could be some weird string with no path that actually wants to
//reference the parentName's path. //reference the parentName's path.
plugin.load(map.name, makeRequire(map.parentMap, true, function (deps, cb) { plugin.load(map.name, makeRequire(map.parentMap, true, function (deps, cb, er) {
deps.rjsSkipMap = true; deps.rjsSkipMap = true;
return context.require(deps, cb); return context.require(deps, cb, er);
}), load, config); }), load, config);
})); }));
@@ -1209,7 +1224,7 @@ var requirejs, require, define;
this.check(); this.check();
}, },
on: function(name, cb) { on: function (name, cb) {
var cbs = this.events[name]; var cbs = this.events[name];
if (!cbs) { if (!cbs) {
cbs = this.events[name] = []; cbs = this.events[name] = [];
@@ -1362,7 +1377,12 @@ var requirejs, require, define;
//update the maps for them, since their info, like URLs to load, //update the maps for them, since their info, like URLs to load,
//may have changed. //may have changed.
eachProp(registry, function (mod, id) { eachProp(registry, function (mod, id) {
mod.map = makeModuleMap(id); //If module already has init called, since it is too
//late to modify them, and ignore unnormalized ones
//since they are transient.
if (!mod.inited && !mod.map.unnormalized) {
mod.map = makeModuleMap(id);
}
}); });
//If a deps array or a config callback is specified, then call //If a deps array or a config callback is specified, then call
@@ -1471,6 +1491,10 @@ var requirejs, require, define;
}, },
undef: function (id) { undef: function (id) {
//Bind any waiting define() calls to this context,
//fix for #408
takeGlobalQueue();
var map = makeModuleMap(id, null, true), var map = makeModuleMap(id, null, true),
mod = registry[id]; mod = registry[id];
@@ -1509,9 +1533,9 @@ var requirejs, require, define;
* @param {String} moduleName the name of the module to potentially complete. * @param {String} moduleName the name of the module to potentially complete.
*/ */
completeLoad: function (moduleName) { completeLoad: function (moduleName) {
var shim = config.shim[moduleName] || {}, var found, args, mod,
shExports = shim.exports && shim.exports.exports, shim = config.shim[moduleName] || {},
found, args, mod; shExports = shim.exports && shim.exports.exports;
takeGlobalQueue(); takeGlobalQueue();
@@ -1538,9 +1562,7 @@ var requirejs, require, define;
//of those calls/init calls changes the registry. //of those calls/init calls changes the registry.
mod = registry[moduleName]; mod = registry[moduleName];
if (!found && if (!found && !defined[moduleName] && mod && !mod.inited) {
!defined[moduleName] &&
mod && !mod.inited) {
if (config.enforceDefine && (!shExports || !getGlobal(shExports))) { if (config.enforceDefine && (!shExports || !getGlobal(shExports))) {
if (hasPathFallback(moduleName)) { if (hasPathFallback(moduleName)) {
return; return;
@@ -1633,7 +1655,8 @@ var requirejs, require, define;
} }
//Join the path parts together, then figure out if baseUrl is needed. //Join the path parts together, then figure out if baseUrl is needed.
url = syms.join('/') + (ext || '.js'); url = syms.join('/');
url += (ext || (/\?/.test(url) ? '' : '.js'));
url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url; url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url;
} }
@@ -1670,7 +1693,7 @@ var requirejs, require, define;
//all old browsers will be supported, but this one was easy enough //all old browsers will be supported, but this one was easy enough
//to support and still makes sense. //to support and still makes sense.
if (evt.type === 'load' || 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 //Reset interactive script so a script node is not held onto for
//to long. //to long.
interactiveScript = null; interactiveScript = null;
@@ -1710,8 +1733,8 @@ var requirejs, require, define;
req = requirejs = function (deps, callback, errback, optional) { req = requirejs = function (deps, callback, errback, optional) {
//Find the right context, use default //Find the right context, use default
var contextName = defContextName, var context, config,
context, config; contextName = defContextName;
// Determine if have config object in the call. // Determine if have config object in the call.
if (!isArray(deps) && typeof deps !== 'string') { if (!isArray(deps) && typeof deps !== 'string') {
@@ -1810,8 +1833,8 @@ var requirejs, require, define;
if (isBrowser) { if (isBrowser) {
//In the browser so use a script tag //In the browser so use a script tag
node = config.xhtml ? node = config.xhtml ?
document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') : document.createElementNS('http://www.w3.org/1999/xhtml', 'html:script') :
document.createElement('script'); document.createElement('script');
node.type = config.scriptType || 'text/javascript'; node.type = config.scriptType || 'text/javascript';
node.charset = 'utf-8'; node.charset = 'utf-8';
node.async = true; node.async = true;
@@ -1828,15 +1851,15 @@ var requirejs, require, define;
//UNFORTUNATELY Opera implements attachEvent but does not follow the script //UNFORTUNATELY Opera implements attachEvent but does not follow the script
//script execution mode. //script execution mode.
if (node.attachEvent && if (node.attachEvent &&
//Check if node.attachEvent is artificially added by custom script or //Check if node.attachEvent is artificially added by custom script or
//natively supported by browser //natively supported by browser
//read https://github.com/jrburke/requirejs/issues/187 //read https://github.com/jrburke/requirejs/issues/187
//if we can NOT find [native code] then it must NOT natively supported. //if we can NOT find [native code] then it must NOT natively supported.
//in IE8, node.attachEvent does not have toString() //in IE8, node.attachEvent does not have toString()
//Note the test for "[native code" with no closing brace, see: //Note the test for "[native code" with no closing brace, see:
//https://github.com/jrburke/requirejs/issues/273 //https://github.com/jrburke/requirejs/issues/273
!(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) && !(node.attachEvent.toString && node.attachEvent.toString().indexOf('[native code') < 0) &&
!isOpera) { !isOpera) {
//Probably IE. IE (at least 6-8) do not fire //Probably IE. IE (at least 6-8) do not fire
//script onload right after executing the script, so //script onload right after executing the script, so
//we cannot tie the anonymous define call to a name. //we cannot tie the anonymous define call to a name.