Commit bf2698d5 authored by Pascal Hartig's avatar Pascal Hartig

Flight: Upgrade to 1.1.1

parent 16adcca6
...@@ -4,16 +4,14 @@ ...@@ -4,16 +4,14 @@
// http://opensource.org/licenses/MIT // http://opensource.org/licenses/MIT
// ========================================== // ==========================================
"use strict";
define( define(
[ [
'./utils',
'./compose' './compose'
], ],
function (util, compose) { function(compose) {
'use strict';
var advice = { var advice = {
...@@ -25,7 +23,7 @@ define( ...@@ -25,7 +23,7 @@ define(
for (; i < l; i++) args[i + 1] = arguments[i]; for (; i < l; i++) args[i + 1] = arguments[i];
return wrapped.apply(this, args); return wrapped.apply(this, args);
} };
}, },
before: function(base, before) { before: function(base, before) {
...@@ -33,7 +31,7 @@ define( ...@@ -33,7 +31,7 @@ define(
return function composedBefore() { return function composedBefore() {
beforeFn.apply(this, arguments); beforeFn.apply(this, arguments);
return base.apply(this, arguments); return base.apply(this, arguments);
} };
}, },
after: function(base, after) { after: function(base, after) {
...@@ -42,7 +40,7 @@ define( ...@@ -42,7 +40,7 @@ define(
var res = (base.unbound || base).apply(this, arguments); var res = (base.unbound || base).apply(this, arguments);
afterFn.apply(this, arguments); afterFn.apply(this, arguments);
return res; return res;
} };
}, },
// a mixin that allows other mixins to augment existing functions by adding additional // a mixin that allows other mixins to augment existing functions by adding additional
...@@ -53,10 +51,12 @@ define( ...@@ -53,10 +51,12 @@ define(
compose.unlockProperty(this, method, function() { compose.unlockProperty(this, method, function() {
if (typeof this[method] == 'function') { if (typeof this[method] == 'function') {
return this[method] = advice[m](this[method], fn); this[method] = advice[m](this[method], fn);
} else { } else {
return this[method] = fn; this[method] = fn;
} }
return this[method];
}); });
}; };
......
// ==========================================
// Copyright 2013 Twitter, Inc
// Licensed under The MIT License
// http://opensource.org/licenses/MIT
// ==========================================
define( define(
[ [
'./utils', './utils',
'./registry', './registry',
'./debug' './debug'
], ],
function(utils, registry, debug) { function(utils, registry, debug) {
//common mixin allocates basic functionality - used by all component prototypes 'use strict';
//callback context is bound to component
// common mixin allocates basic functionality - used by all component prototypes
// callback context is bound to component
var componentId = 0; var componentId = 0;
function teardownInstance(instanceInfo){ function teardownInstance(instanceInfo){
...@@ -26,7 +36,7 @@ define( ...@@ -26,7 +36,7 @@ define(
} catch(e) { } catch(e) {
console.log('unserializable data for event',type,':',data); console.log('unserializable data for event',type,':',data);
throw new Error( throw new Error(
["The event", type, "on component", this.toString(), "was triggered with non-serializable data"].join(" ") ['The event', type, 'on component', this.toString(), 'was triggered with non-serializable data'].join(' ')
); );
} }
} }
...@@ -43,7 +53,7 @@ define( ...@@ -43,7 +53,7 @@ define(
var $element, type, data, event, defaultFn; var $element, type, data, event, defaultFn;
var lastIndex = arguments.length - 1, lastArg = arguments[lastIndex]; var lastIndex = arguments.length - 1, lastArg = arguments[lastIndex];
if (typeof lastArg != "string" && !(lastArg && lastArg.defaultBehavior)) { if (typeof lastArg != 'string' && !(lastArg && lastArg.defaultBehavior)) {
lastIndex--; lastIndex--;
data = lastArg; data = lastArg;
} }
...@@ -84,7 +94,7 @@ define( ...@@ -84,7 +94,7 @@ define(
var $element, type, callback, originalCb; var $element, type, callback, originalCb;
var lastIndex = arguments.length - 1, origin = arguments[lastIndex]; var lastIndex = arguments.length - 1, origin = arguments[lastIndex];
if (typeof origin == "object") { if (typeof origin == 'object') {
//delegate callback //delegate callback
originalCb = utils.delegate( originalCb = utils.delegate(
this.resolveDelegateRules(origin) this.resolveDelegateRules(origin)
...@@ -102,7 +112,7 @@ define( ...@@ -102,7 +112,7 @@ define(
} }
if (typeof originalCb != 'function' && typeof originalCb != 'object') { if (typeof originalCb != 'function' && typeof originalCb != 'object') {
throw new Error("Unable to bind to '" + type + "' because the given callback is not a function or an object"); throw new Error('Unable to bind to "' + type + '" because the given callback is not a function or an object');
} }
callback = originalCb.bind(this); callback = originalCb.bind(this);
...@@ -125,7 +135,7 @@ define( ...@@ -125,7 +135,7 @@ define(
var $element, type, callback; var $element, type, callback;
var lastIndex = arguments.length - 1; var lastIndex = arguments.length - 1;
if (typeof arguments[lastIndex] == "function") { if (typeof arguments[lastIndex] == 'function') {
callback = arguments[lastIndex]; callback = arguments[lastIndex];
lastIndex -= 1; lastIndex -= 1;
} }
...@@ -163,11 +173,12 @@ define( ...@@ -163,11 +173,12 @@ define(
}; };
this.initialize = function(node, attrs) { this.initialize = function(node, attrs) {
attrs = attrs || {}; attrs || (attrs = {});
this.identity = componentId++; //only assign identity if there isn't one (initialize can be called multiple times)
this.identity || (this.identity = componentId++);
if (!node) { if (!node) {
throw new Error("Component needs a node"); throw new Error('Component needs a node');
} }
if (node.jquery) { if (node.jquery) {
...@@ -178,8 +189,8 @@ define( ...@@ -178,8 +189,8 @@ define(
this.$node = $(node); this.$node = $(node);
} }
//merge defaults with supplied options // merge defaults with supplied options
//put options in attr.__proto__ to avoid merge overhead // put options in attr.__proto__ to avoid merge overhead
var attr = Object.create(attrs); var attr = Object.create(attrs);
for (var key in this.defaults) { for (var key in this.defaults) {
if (!attrs.hasOwnProperty(key)) { if (!attrs.hasOwnProperty(key)) {
...@@ -196,7 +207,7 @@ define( ...@@ -196,7 +207,7 @@ define(
}, this); }, this);
return this; return this;
} };
this.teardown = function() { this.teardown = function() {
teardownInstance(registry.findInstanceInfo(this)); teardownInstance(registry.findInstanceInfo(this));
...@@ -204,4 +215,5 @@ define( ...@@ -204,4 +215,5 @@ define(
} }
return withBase; return withBase;
}); }
);
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
// http://opensource.org/licenses/MIT // http://opensource.org/licenses/MIT
// ========================================== // ==========================================
"use strict";
define( define(
[ [
...@@ -19,10 +17,11 @@ define( ...@@ -19,10 +17,11 @@ define(
], ],
function(advice, utils, compose, withBase, registry, withLogging, debug) { function(advice, utils, compose, withBase, registry, withLogging, debug) {
'use strict';
var functionNameRegEx = /function (.*?)\s?\(/; var functionNameRegEx = /function (.*?)\s?\(/;
//teardown for all instances of this constructor // teardown for all instances of this constructor
function teardownAll() { function teardownAll() {
var componentInfo = registry.findComponentInfo(this); var componentInfo = registry.findComponentInfo(this);
...@@ -38,7 +37,7 @@ define( ...@@ -38,7 +37,7 @@ define(
} catch(e) { } catch(e) {
console.log('unserializable data for event',type,':',data); console.log('unserializable data for event',type,':',data);
throw new Error( throw new Error(
["The event", type, "on component", this.toString(), "was triggered with non-serializable data"].join(" ") ['The event', type, 'on component', this.toString(), 'was triggered with non-serializable data'].join(' ')
); );
} }
} }
...@@ -50,16 +49,15 @@ define( ...@@ -50,16 +49,15 @@ define(
for (var i = 1; i < l; i++) args[i - 1] = arguments[i]; for (var i = 1; i < l; i++) args[i - 1] = arguments[i];
if (!selector) { if (!selector) {
throw new Error("Component needs to be attachTo'd a jQuery object, native node or selector string"); throw new Error('Component needs to be attachTo\'d a jQuery object, native node or selector string');
} }
var options = utils.merge.apply(utils, args); var options = utils.merge.apply(utils, args);
var componentInfo = registry.findComponentInfo(this);
$(selector).each(function(i, node) { $(selector).each(function(i, node) {
var rawNode = node.jQuery ? node[0] : node; if (componentInfo && componentInfo.isAttachedTo(node)) {
var componentInfo = registry.findComponentInfo(this) // already attached
if (componentInfo && componentInfo.isAttachedTo(rawNode)) {
//already attached
return; return;
} }
...@@ -73,7 +71,8 @@ define( ...@@ -73,7 +71,8 @@ define(
function define(/*mixins*/) { function define(/*mixins*/) {
// unpacking arguments by hand benchmarked faster // unpacking arguments by hand benchmarked faster
var l = arguments.length; var l = arguments.length;
var mixins = new Array(l + 3); //add three for common mixins // add three for common mixins
var mixins = new Array(l + 3);
for (var i = 0; i < l; i++) mixins[i] = arguments[i]; for (var i = 0; i < l; i++) mixins[i] = arguments[i];
var Component = function() {}; var Component = function() {};
...@@ -81,11 +80,11 @@ define( ...@@ -81,11 +80,11 @@ define(
Component.toString = Component.prototype.toString = function() { Component.toString = Component.prototype.toString = function() {
var prettyPrintMixins = mixins.map(function(mixin) { var prettyPrintMixins = mixins.map(function(mixin) {
if (mixin.name == null) { if (mixin.name == null) {
//function name property not supported by this browser, use regex // function name property not supported by this browser, use regex
var m = mixin.toString().match(functionNameRegEx); var m = mixin.toString().match(functionNameRegEx);
return (m && m[1]) ? m[1] : ""; return (m && m[1]) ? m[1] : '';
} else { } else {
return (mixin.name != "withBase") ? mixin.name : ""; return (mixin.name != 'withBase') ? mixin.name : '';
} }
}).filter(Boolean).join(', '); }).filter(Boolean).join(', ');
return prettyPrintMixins; return prettyPrintMixins;
...@@ -95,7 +94,7 @@ define( ...@@ -95,7 +94,7 @@ define(
Component.describe = Component.prototype.describe = Component.toString(); Component.describe = Component.prototype.describe = Component.toString();
} }
//'options' is optional hash to be merged with 'defaults' in the component definition // 'options' is optional hash to be merged with 'defaults' in the component definition
Component.attachTo = attachTo; Component.attachTo = attachTo;
Component.teardownAll = teardownAll; Component.teardownAll = teardownAll;
......
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
// http://opensource.org/licenses/MIT // http://opensource.org/licenses/MIT
// ========================================== // ==========================================
"use strict";
define( define(
[ [
...@@ -13,10 +11,11 @@ define( ...@@ -13,10 +11,11 @@ define(
'./debug' './debug'
], ],
function(util, debug) { function(utils, debug) {
'use strict';
//enumerables are shims - getOwnPropertyDescriptor shim doesn't work //enumerables are shims - getOwnPropertyDescriptor shim doesn't work
var canWriteProtect = debug.enabled && !util.isEnumerable(Object, 'getOwnPropertyDescriptor'); var canWriteProtect = debug.enabled && !utils.isEnumerable(Object, 'getOwnPropertyDescriptor');
//whitelist of unlockable property names //whitelist of unlockable property names
var dontLock = ['mixedIn']; var dontLock = ['mixedIn'];
......
"use strict"; // ==========================================
// Copyright 2013 Twitter, Inc
// Licensed under The MIT License
// http://opensource.org/licenses/MIT
// ==========================================
define([], function() { define(
var logFilter; [],
function() {
'use strict';
//****************************************************************************************** //******************************************************************************************
// Search object model // Search object model
//****************************************************************************************** //******************************************************************************************
function traverse(util, searchTerm, options) { function traverse(util, searchTerm, options) {
var options = options || {}; options = options || {};
var obj = options.obj || window; var obj = options.obj || window;
var path = options.path || ((obj==window) ? "window" : ""); var path = options.path || ((obj==window) ? 'window' : '');
var props = Object.keys(obj); var props = Object.keys(obj);
props.forEach(function(prop) { props.forEach(function(prop) {
if ((tests[util] || util)(searchTerm, obj, prop)){ if ((tests[util] || util)(searchTerm, obj, prop)){
console.log([path, ".", prop].join(""), "->",["(", typeof obj[prop], ")"].join(""), obj[prop]); console.log([path, '.', prop].join(''), '->', ['(', typeof obj[prop], ')'].join(''), obj[prop]);
} }
if(Object.prototype.toString.call(obj[prop])=="[object Object]" && (obj[prop] != obj) && path.split(".").indexOf(prop) == -1) { if (Object.prototype.toString.call(obj[prop]) == '[object Object]' && (obj[prop] != obj) && path.split('.').indexOf(prop) == -1) {
traverse(util, searchTerm, {obj: obj[prop], path: [path,prop].join(".")}); traverse(util, searchTerm, {obj: obj[prop], path: [path,prop].join('.')});
} }
}); });
} }
...@@ -27,24 +34,24 @@ define([], function() { ...@@ -27,24 +34,24 @@ define([], function() {
if (!expected || typeof searchTerm == expected) { if (!expected || typeof searchTerm == expected) {
traverse(util, searchTerm, options); traverse(util, searchTerm, options);
} else { } else {
console.error([searchTerm, 'must be', expected].join(' ')) console.error([searchTerm, 'must be', expected].join(' '));
} }
} }
var tests = { var tests = {
'name': function(searchTerm, obj, prop) {return searchTerm == prop}, 'name': function(searchTerm, obj, prop) {return searchTerm == prop;},
'nameContains': function(searchTerm, obj, prop) {return prop.indexOf(searchTerm)>-1}, 'nameContains': function(searchTerm, obj, prop) {return prop.indexOf(searchTerm) > -1;},
'type': function(searchTerm, obj, prop) {return obj[prop] instanceof searchTerm}, 'type': function(searchTerm, obj, prop) {return obj[prop] instanceof searchTerm;},
'value': function(searchTerm, obj, prop) {return obj[prop] === searchTerm}, 'value': function(searchTerm, obj, prop) {return obj[prop] === searchTerm;},
'valueCoerced': function(searchTerm, obj, prop) {return obj[prop] == searchTerm} 'valueCoerced': function(searchTerm, obj, prop) {return obj[prop] == searchTerm;}
} };
function byName(searchTerm, options) {search('name', 'string', searchTerm, options);}; function byName(searchTerm, options) {search('name', 'string', searchTerm, options);}
function byNameContains(searchTerm, options) {search('nameContains', 'string', searchTerm, options);}; function byNameContains(searchTerm, options) {search('nameContains', 'string', searchTerm, options);}
function byType(searchTerm, options) {search('type', 'function', searchTerm, options);}; function byType(searchTerm, options) {search('type', 'function', searchTerm, options);}
function byValue(searchTerm, options) {search('value', null, searchTerm, options);}; function byValue(searchTerm, options) {search('value', null, searchTerm, options);}
function byValueCoerced(searchTerm, options) {search('valueCoerced', null, searchTerm, options);}; function byValueCoerced(searchTerm, options) {search('valueCoerced', null, searchTerm, options);}
function custom(fn, options) {traverse(fn, null, options);}; function custom(fn, options) {traverse(fn, null, options);}
//****************************************************************************************** //******************************************************************************************
// Event logging // Event logging
...@@ -98,7 +105,8 @@ define([], function() { ...@@ -98,7 +105,8 @@ define([], function() {
eventNames: (window.localStorage && localStorage.getItem('logFilter_eventNames')) || defaultEventNamesFilter, eventNames: (window.localStorage && localStorage.getItem('logFilter_eventNames')) || defaultEventNamesFilter,
actions: (window.localStorage && localStorage.getItem('logFilter_actions')) || defaultActionsFilter actions: (window.localStorage && localStorage.getItem('logFilter_actions')) || defaultActionsFilter
}; };
//reconstitute arrays
// reconstitute arrays
Object.keys(result).forEach(function(k) { Object.keys(result).forEach(function(k) {
var thisProp = result[k]; var thisProp = result[k];
if (typeof thisProp == 'string' && thisProp !== ALL) { if (typeof thisProp == 'string' && thisProp !== ALL) {
...@@ -147,4 +155,3 @@ define([], function() { ...@@ -147,4 +155,3 @@ define([], function() {
}; };
} }
); );
...@@ -15,7 +15,8 @@ define( ...@@ -15,7 +15,8 @@ define(
'./utils' './utils'
], ],
function (advice, component, compose, logger, registry, utils) { function(advice, component, compose, logger, registry, utils) {
'use strict';
return { return {
advice: advice, advice: advice,
......
...@@ -4,41 +4,38 @@ ...@@ -4,41 +4,38 @@
// http://opensource.org/licenses/MIT // http://opensource.org/licenses/MIT
// ========================================== // ==========================================
"use strict";
define( define(
[ [
'./compose',
'./utils' './utils'
], ],
function (compose, util) { function(utils) {
'use strict';
var actionSymbols = { var actionSymbols = {
on:'<-', on: '<-',
trigger: '->', trigger: '->',
off: 'x ' off: 'x '
}; };
function elemToString(elem) { function elemToString(elem) {
var tagStr = elem.tagName ? elem.tagName.toLowerCase() : elem.toString(); var tagStr = elem.tagName ? elem.tagName.toLowerCase() : elem.toString();
var classStr = elem.className ? "." + (elem.className) : ""; var classStr = elem.className ? '.' + (elem.className) : '';
var result = tagStr + classStr; var result = tagStr + classStr;
return elem.tagName ? ['\'', '\''].join(result) : result; return elem.tagName ? ['\'', '\''].join(result) : result;
} }
function log(action, component, eventArgs) { function log(action, component, eventArgs) {
var name, elem, fn, logFilter, toRegExp, actionLoggable, nameLoggable;
var name, elem, fn, fnName, logFilter, toRegExp, actionLoggable, nameLoggable;
if (typeof eventArgs[eventArgs.length-1] == 'function') { if (typeof eventArgs[eventArgs.length-1] == 'function') {
fn = eventArgs.pop(); fn = eventArgs.pop();
fn = fn.unbound || fn; //use unbound version if any (better info) fn = fn.unbound || fn; // use unbound version if any (better info)
} }
if (typeof eventArgs[eventArgs.length - 1] == 'object') { if (typeof eventArgs[eventArgs.length - 1] == 'object') {
eventArgs.pop(); //trigger data arg - not logged right now eventArgs.pop(); // trigger data arg - not logged right now
} }
if (eventArgs.length == 2) { if (eventArgs.length == 2) {
...@@ -53,14 +50,14 @@ define( ...@@ -53,14 +50,14 @@ define(
logFilter = DEBUG.events.logFilter; logFilter = DEBUG.events.logFilter;
// no regex for you, actions... // no regex for you, actions...
actionLoggable = logFilter.actions=="all" || (logFilter.actions.indexOf(action) > -1); actionLoggable = logFilter.actions == 'all' || (logFilter.actions.indexOf(action) > -1);
// event name filter allow wildcards or regex... // event name filter allow wildcards or regex...
toRegExp = function(expr) { toRegExp = function(expr) {
return expr.test ? expr : new RegExp("^" + expr.replace(/\*/g, ".*") + "$"); return expr.test ? expr : new RegExp('^' + expr.replace(/\*/g, '.*') + '$');
}; };
nameLoggable = nameLoggable =
logFilter.eventNames=="all" || logFilter.eventNames == 'all' ||
logFilter.eventNames.some(function(e) {return toRegExp(e).test(name)}); logFilter.eventNames.some(function(e) {return toRegExp(e).test(name);});
if (actionLoggable && nameLoggable) { if (actionLoggable && nameLoggable) {
console.info( console.info(
...@@ -68,7 +65,7 @@ define( ...@@ -68,7 +65,7 @@ define(
action, action,
'[' + name + ']', '[' + name + ']',
elemToString(elem), elemToString(elem),
component.constructor.describe.split(' ').slice(0,3).join(' ') //two mixins only component.constructor.describe.split(' ').slice(0,3).join(' ') // two mixins only
); );
} }
} }
...@@ -76,13 +73,13 @@ define( ...@@ -76,13 +73,13 @@ define(
function withLogging() { function withLogging() {
this.before('trigger', function() { this.before('trigger', function() {
log('trigger', this, util.toArray(arguments)); log('trigger', this, utils.toArray(arguments));
}); });
this.before('on', function() { this.before('on', function() {
log('on', this, util.toArray(arguments)); log('on', this, utils.toArray(arguments));
}); });
this.before('off', function(eventArgs) { this.before('off', function() {
log('off', this, util.toArray(arguments)); log('off', this, utils.toArray(arguments));
}); });
} }
......
...@@ -4,15 +4,12 @@ ...@@ -4,15 +4,12 @@
// http://opensource.org/licenses/MIT // http://opensource.org/licenses/MIT
// ========================================== // ==========================================
"use strict";
define( define(
[ [],
'./utils'
],
function (util) { function() {
'use strict';
function parseEventArgs(instance, args) { function parseEventArgs(instance, args) {
var element, type, callback; var element, type, callback;
...@@ -71,7 +68,7 @@ define( ...@@ -71,7 +68,7 @@ define(
this.attachedTo.push(instance.node); this.attachedTo.push(instance.node);
return instanceInfo; return instanceInfo;
} };
this.removeInstance = function(instance) { this.removeInstance = function(instance) {
delete this.instances[instance.identity]; delete this.instances[instance.identity];
...@@ -82,11 +79,11 @@ define( ...@@ -82,11 +79,11 @@ define(
//if I hold no more instances remove me from registry //if I hold no more instances remove me from registry
registry.removeComponentInfo(this); registry.removeComponentInfo(this);
} }
} };
this.isAttachedTo = function(node) { this.isAttachedTo = function(node) {
return this.attachedTo.indexOf(node) > -1; return this.attachedTo.indexOf(node) > -1;
} };
} }
function InstanceInfo(instance) { function InstanceInfo(instance) {
...@@ -104,7 +101,7 @@ define( ...@@ -104,7 +101,7 @@ define(
this.events.splice(i, 1); this.events.splice(i, 1);
} }
} }
} };
} }
this.addInstance = function(instance) { this.addInstance = function(instance) {
...@@ -158,7 +155,7 @@ define( ...@@ -158,7 +155,7 @@ define(
var result = []; var result = [];
Object.keys(this.allInstances).forEach(function(k) { Object.keys(this.allInstances).forEach(function(k) {
var thisInstanceInfo = this.allInstances[k]; var thisInstanceInfo = this.allInstances[k];
if(thisInstanceInfo.instance.node === node) { if (thisInstanceInfo.instance.node === node) {
result.push(thisInstanceInfo); result.push(thisInstanceInfo);
} }
}, this); }, this);
...@@ -183,7 +180,7 @@ define( ...@@ -183,7 +180,7 @@ define(
} }
}; };
this.off = function(el, type, callback) { this.off = function(/*el, type, callback*/) {
var event = parseEventArgs(this, arguments), var event = parseEventArgs(this, arguments),
instance = registry.findInstanceInfo(this); instance = registry.findInstanceInfo(this);
...@@ -199,8 +196,8 @@ define( ...@@ -199,8 +196,8 @@ define(
} }
}; };
//debug tools may want to add advice to trigger // debug tools may want to add advice to trigger
registry.trigger = new Function; registry.trigger = function() {};
this.teardown = function() { this.teardown = function() {
registry.removeInstance(this); registry.removeInstance(this);
...@@ -215,7 +212,7 @@ define( ...@@ -215,7 +212,7 @@ define(
this.after('off', registry.off); this.after('off', registry.off);
//debug tools may want to add advice to trigger //debug tools may want to add advice to trigger
window.DEBUG && DEBUG.enabled && this.after('trigger', registry.trigger); window.DEBUG && DEBUG.enabled && this.after('trigger', registry.trigger);
this.after('teardown', {obj:registry, fnName:'teardown'}); this.after('teardown', {obj: registry, fnName: 'teardown'});
}; };
} }
......
...@@ -4,13 +4,12 @@ ...@@ -4,13 +4,12 @@
// http://opensource.org/licenses/MIT // http://opensource.org/licenses/MIT
// ========================================== // ==========================================
"use strict";
define( define(
[], [],
function () { function() {
'use strict';
var arry = []; var arry = [];
var DEFAULT_INTERVAL = 100; var DEFAULT_INTERVAL = 100;
...@@ -92,14 +91,14 @@ define( ...@@ -92,14 +91,14 @@ define(
if (base) { if (base) {
Object.keys(extra || {}).forEach(function(key) { Object.keys(extra || {}).forEach(function(key) {
if (base[key] && protect) { if (base[key] && protect) {
throw Error("utils.push attempted to overwrite '" + key + "' while running in protected mode"); throw new Error('utils.push attempted to overwrite "' + key + '" while running in protected mode');
} }
if (typeof base[key] == "object" && typeof extra[key] == "object") { if (typeof base[key] == 'object' && typeof extra[key] == 'object') {
//recurse // recurse
this.push(base[key], extra[key]); this.push(base[key], extra[key]);
} else { } else {
//no protect, so extra wins // no protect, so extra wins
base[key] = extra[key]; base[key] = extra[key];
} }
}, this); }, this);
...@@ -112,9 +111,9 @@ define( ...@@ -112,9 +111,9 @@ define(
return Object.keys(obj).indexOf(property) > -1; return Object.keys(obj).indexOf(property) > -1;
}, },
//build a function from other function(s) // build a function from other function(s)
//util.compose(a,b,c) -> a(b(c())); // utils.compose(a,b,c) -> a(b(c()));
//implementation lifted from underscore.js (c) 2009-2012 Jeremy Ashkenas // implementation lifted from underscore.js (c) 2009-2012 Jeremy Ashkenas
compose: function() { compose: function() {
var funcs = arguments; var funcs = arguments;
......
/** vim: et:ts=4:sw=4:sts=4 /** vim: et:ts=4:sw=4:sts=4
* @license RequireJS 2.1.8 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved. * @license RequireJS 2.1.9 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
*/ */
...@@ -12,7 +12,7 @@ var requirejs, require, define; ...@@ -12,7 +12,7 @@ var requirejs, require, define;
(function (global) { (function (global) {
var req, s, head, baseElement, dataMain, src, var req, s, head, baseElement, dataMain, src,
interactiveScript, currentlyAddingScript, mainScript, subPath, interactiveScript, currentlyAddingScript, mainScript, subPath,
version = '2.1.8', version = '2.1.9',
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$/,
...@@ -22,7 +22,7 @@ var requirejs, require, define; ...@@ -22,7 +22,7 @@ var requirejs, require, define;
hasOwn = op.hasOwnProperty, hasOwn = op.hasOwnProperty,
ap = Array.prototype, ap = Array.prototype,
apsp = ap.splice, apsp = ap.splice,
isBrowser = !!(typeof window !== 'undefined' && navigator && window.document), isBrowser = !!(typeof window !== 'undefined' && typeof navigator !== 'undefined' && window.document),
isWebWorker = !isBrowser && typeof importScripts !== 'undefined', isWebWorker = !isBrowser && typeof importScripts !== 'undefined',
//PS3 indicates loaded and complete, but need to wait for complete //PS3 indicates loaded and complete, but need to wait for complete
//specifically. Sequence is 'loading', 'loaded', execution, //specifically. Sequence is 'loading', 'loaded', execution,
...@@ -373,7 +373,6 @@ var requirejs, require, define; ...@@ -373,7 +373,6 @@ var requirejs, require, define;
function hasPathFallback(id) { function hasPathFallback(id) {
var pathConfig = getOwn(config.paths, id); var pathConfig = getOwn(config.paths, id);
if (pathConfig && isArray(pathConfig) && pathConfig.length > 1) { if (pathConfig && isArray(pathConfig) && pathConfig.length > 1) {
removeScript(id);
//Pop off the first array value, since it failed, and //Pop off the first array value, since it failed, and
//retry //retry
pathConfig.shift(); pathConfig.shift();
...@@ -1464,6 +1463,8 @@ var requirejs, require, define; ...@@ -1464,6 +1463,8 @@ var requirejs, require, define;
var map = makeModuleMap(id, relMap, true), var map = makeModuleMap(id, relMap, true),
mod = getOwn(registry, id); mod = getOwn(registry, id);
removeScript(id);
delete defined[id]; delete defined[id];
delete urlFetched[map.url]; delete urlFetched[map.url];
delete undefEvents[id]; delete undefEvents[id];
...@@ -1609,7 +1610,7 @@ var requirejs, require, define; ...@@ -1609,7 +1610,7 @@ 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('/'); url = syms.join('/');
url += (ext || (/\?/.test(url) || skipExt ? '' : '.js')); url += (ext || (/^data\:|\?/.test(url) || skipExt ? '' : '.js'));
url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url; url = (url.charAt(0) === '/' || url.match(/^[\w\+\.\-]+:/) ? '' : config.baseUrl) + url;
} }
...@@ -1918,7 +1919,7 @@ var requirejs, require, define; ...@@ -1918,7 +1919,7 @@ var requirejs, require, define;
} }
//Look for a data-main script attribute, which could also adjust the baseUrl. //Look for a data-main script attribute, which could also adjust the baseUrl.
if (isBrowser) { if (isBrowser && !cfg.skipDataMain) {
//Figure out baseUrl. Get it from the script tag with require.js in it. //Figure out baseUrl. Get it from the script tag with require.js in it.
eachReverse(scripts(), function (script) { eachReverse(scripts(), function (script) {
//Set the 'head' where we can append children by //Set the 'head' where we can append children by
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment