External Libraries: Update Backbone to version 1.3.3.
Changelog: https://cdn.rawgit.com/jashkenas/backbone/1.3.3/index.html#changelog Diff: https://github.com/jashkenas/backbone/compare/1.2.3...1.3.3 Includes a unit test to ensure that the minified version doesn't include `sourceMappingURL`. Props adamsilverstein. Fixes #37099. git-svn-id: https://develop.svn.wordpress.org/trunk@37723 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
70afec2875
commit
62bd8ecdd7
|
@ -1,6 +1,6 @@
|
||||||
// Backbone.js 1.2.3
|
// Backbone.js 1.3.3
|
||||||
|
|
||||||
// (c) 2010-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
// (c) 2010-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
||||||
// Backbone may be freely distributed under the MIT license.
|
// Backbone may be freely distributed under the MIT license.
|
||||||
// For all details and documentation:
|
// For all details and documentation:
|
||||||
// http://backbonejs.org
|
// http://backbonejs.org
|
||||||
|
@ -9,8 +9,8 @@
|
||||||
|
|
||||||
// Establish the root object, `window` (`self`) in the browser, or `global` on the server.
|
// Establish the root object, `window` (`self`) in the browser, or `global` on the server.
|
||||||
// We use `self` instead of `window` for `WebWorker` support.
|
// We use `self` instead of `window` for `WebWorker` support.
|
||||||
var root = (typeof self == 'object' && self.self == self && self) ||
|
var root = (typeof self == 'object' && self.self === self && self) ||
|
||||||
(typeof global == 'object' && global.global == global && global);
|
(typeof global == 'object' && global.global === global && global);
|
||||||
|
|
||||||
// Set up Backbone appropriately for the environment. Start with AMD.
|
// Set up Backbone appropriately for the environment. Start with AMD.
|
||||||
if (typeof define === 'function' && define.amd) {
|
if (typeof define === 'function' && define.amd) {
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
root.Backbone = factory(root, {}, root._, (root.jQuery || root.Zepto || root.ender || root.$));
|
root.Backbone = factory(root, {}, root._, (root.jQuery || root.Zepto || root.ender || root.$));
|
||||||
}
|
}
|
||||||
|
|
||||||
}(function(root, Backbone, _, $) {
|
})(function(root, Backbone, _, $) {
|
||||||
|
|
||||||
// Initial Setup
|
// Initial Setup
|
||||||
// -------------
|
// -------------
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
var slice = Array.prototype.slice;
|
var slice = Array.prototype.slice;
|
||||||
|
|
||||||
// Current version of the library. Keep in sync with `package.json`.
|
// Current version of the library. Keep in sync with `package.json`.
|
||||||
Backbone.VERSION = '1.2.3';
|
Backbone.VERSION = '1.3.3';
|
||||||
|
|
||||||
// For Backbone's purposes, jQuery, Zepto, Ender, or My Library (kidding) owns
|
// For Backbone's purposes, jQuery, Zepto, Ender, or My Library (kidding) owns
|
||||||
// the `$` variable.
|
// the `$` variable.
|
||||||
|
@ -146,7 +146,7 @@
|
||||||
events = eventsApi(iteratee, events, names[i], name[names[i]], opts);
|
events = eventsApi(iteratee, events, names[i], name[names[i]], opts);
|
||||||
}
|
}
|
||||||
} else if (name && eventSplitter.test(name)) {
|
} else if (name && eventSplitter.test(name)) {
|
||||||
// Handle space separated event names by delegating them individually.
|
// Handle space-separated event names by delegating them individually.
|
||||||
for (names = name.split(eventSplitter); i < names.length; i++) {
|
for (names = name.split(eventSplitter); i < names.length; i++) {
|
||||||
events = iteratee(events, names[i], callback, opts);
|
events = iteratee(events, names[i], callback, opts);
|
||||||
}
|
}
|
||||||
|
@ -242,7 +242,6 @@
|
||||||
|
|
||||||
listening.obj.off(name, callback, this);
|
listening.obj.off(name, callback, this);
|
||||||
}
|
}
|
||||||
if (_.isEmpty(listeningTo)) this._listeningTo = void 0;
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
@ -299,7 +298,7 @@
|
||||||
delete events[name];
|
delete events[name];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_.size(events)) return events;
|
return events;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Bind an event to only be triggered a single time. After the first time
|
// Bind an event to only be triggered a single time. After the first time
|
||||||
|
@ -309,7 +308,8 @@
|
||||||
Events.once = function(name, callback, context) {
|
Events.once = function(name, callback, context) {
|
||||||
// Map the event into a `{event: once}` object.
|
// Map the event into a `{event: once}` object.
|
||||||
var events = eventsApi(onceMap, {}, name, callback, _.bind(this.off, this));
|
var events = eventsApi(onceMap, {}, name, callback, _.bind(this.off, this));
|
||||||
return this.on(events, void 0, context);
|
if (typeof name === 'string' && context == null) callback = void 0;
|
||||||
|
return this.on(events, callback, context);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Inversion-of-control versions of `once`.
|
// Inversion-of-control versions of `once`.
|
||||||
|
@ -348,7 +348,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handles triggering the appropriate event callbacks.
|
// Handles triggering the appropriate event callbacks.
|
||||||
var triggerApi = function(objEvents, name, cb, args) {
|
var triggerApi = function(objEvents, name, callback, args) {
|
||||||
if (objEvents) {
|
if (objEvents) {
|
||||||
var events = objEvents[name];
|
var events = objEvents[name];
|
||||||
var allEvents = objEvents.all;
|
var allEvents = objEvents.all;
|
||||||
|
@ -398,7 +398,8 @@
|
||||||
this.attributes = {};
|
this.attributes = {};
|
||||||
if (options.collection) this.collection = options.collection;
|
if (options.collection) this.collection = options.collection;
|
||||||
if (options.parse) attrs = this.parse(attrs, options) || {};
|
if (options.parse) attrs = this.parse(attrs, options) || {};
|
||||||
attrs = _.defaults({}, attrs, _.result(this, 'defaults'));
|
var defaults = _.result(this, 'defaults');
|
||||||
|
attrs = _.defaults(_.extend({}, defaults, attrs), defaults);
|
||||||
this.set(attrs, options);
|
this.set(attrs, options);
|
||||||
this.changed = {};
|
this.changed = {};
|
||||||
this.initialize.apply(this, arguments);
|
this.initialize.apply(this, arguments);
|
||||||
|
@ -506,7 +507,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the `id`.
|
// Update the `id`.
|
||||||
this.id = this.get(this.idAttribute);
|
if (this.idAttribute in attrs) this.id = this.get(this.idAttribute);
|
||||||
|
|
||||||
// Trigger all relevant attribute changes.
|
// Trigger all relevant attribute changes.
|
||||||
if (!silent) {
|
if (!silent) {
|
||||||
|
@ -619,8 +620,8 @@
|
||||||
// the model will be valid when the attributes, if any, are set.
|
// the model will be valid when the attributes, if any, are set.
|
||||||
if (attrs && !wait) {
|
if (attrs && !wait) {
|
||||||
if (!this.set(attrs, options)) return false;
|
if (!this.set(attrs, options)) return false;
|
||||||
} else {
|
} else if (!this._validate(attrs, options)) {
|
||||||
if (!this._validate(attrs, options)) return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// After a successful server-side save, the client is (optionally)
|
// After a successful server-side save, the client is (optionally)
|
||||||
|
@ -714,7 +715,7 @@
|
||||||
|
|
||||||
// Check if the model is currently in a valid state.
|
// Check if the model is currently in a valid state.
|
||||||
isValid: function(options) {
|
isValid: function(options) {
|
||||||
return this._validate({}, _.defaults({validate: true}, options));
|
return this._validate({}, _.extend({}, options, {validate: true}));
|
||||||
},
|
},
|
||||||
|
|
||||||
// Run validation against the next complete set of model attributes,
|
// Run validation against the next complete set of model attributes,
|
||||||
|
@ -769,7 +770,8 @@
|
||||||
at = Math.min(Math.max(at, 0), array.length);
|
at = Math.min(Math.max(at, 0), array.length);
|
||||||
var tail = Array(array.length - at);
|
var tail = Array(array.length - at);
|
||||||
var length = insert.length;
|
var length = insert.length;
|
||||||
for (var i = 0; i < tail.length; i++) tail[i] = array[i + at];
|
var i;
|
||||||
|
for (i = 0; i < tail.length; i++) tail[i] = array[i + at];
|
||||||
for (i = 0; i < length; i++) array[i + at] = insert[i];
|
for (i = 0; i < length; i++) array[i + at] = insert[i];
|
||||||
for (i = 0; i < tail.length; i++) array[i + length + at] = tail[i];
|
for (i = 0; i < tail.length; i++) array[i + length + at] = tail[i];
|
||||||
};
|
};
|
||||||
|
@ -807,9 +809,12 @@
|
||||||
remove: function(models, options) {
|
remove: function(models, options) {
|
||||||
options = _.extend({}, options);
|
options = _.extend({}, options);
|
||||||
var singular = !_.isArray(models);
|
var singular = !_.isArray(models);
|
||||||
models = singular ? [models] : _.clone(models);
|
models = singular ? [models] : models.slice();
|
||||||
var removed = this._removeModels(models, options);
|
var removed = this._removeModels(models, options);
|
||||||
if (!options.silent && removed) this.trigger('update', this, options);
|
if (!options.silent && removed.length) {
|
||||||
|
options.changes = {added: [], merged: [], removed: removed};
|
||||||
|
this.trigger('update', this, options);
|
||||||
|
}
|
||||||
return singular ? removed[0] : removed;
|
return singular ? removed[0] : removed;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -820,18 +825,22 @@
|
||||||
set: function(models, options) {
|
set: function(models, options) {
|
||||||
if (models == null) return;
|
if (models == null) return;
|
||||||
|
|
||||||
options = _.defaults({}, options, setOptions);
|
options = _.extend({}, setOptions, options);
|
||||||
if (options.parse && !this._isModel(models)) models = this.parse(models, options);
|
if (options.parse && !this._isModel(models)) {
|
||||||
|
models = this.parse(models, options) || [];
|
||||||
|
}
|
||||||
|
|
||||||
var singular = !_.isArray(models);
|
var singular = !_.isArray(models);
|
||||||
models = singular ? [models] : models.slice();
|
models = singular ? [models] : models.slice();
|
||||||
|
|
||||||
var at = options.at;
|
var at = options.at;
|
||||||
if (at != null) at = +at;
|
if (at != null) at = +at;
|
||||||
|
if (at > this.length) at = this.length;
|
||||||
if (at < 0) at += this.length + 1;
|
if (at < 0) at += this.length + 1;
|
||||||
|
|
||||||
var set = [];
|
var set = [];
|
||||||
var toAdd = [];
|
var toAdd = [];
|
||||||
|
var toMerge = [];
|
||||||
var toRemove = [];
|
var toRemove = [];
|
||||||
var modelMap = {};
|
var modelMap = {};
|
||||||
|
|
||||||
|
@ -840,13 +849,13 @@
|
||||||
var remove = options.remove;
|
var remove = options.remove;
|
||||||
|
|
||||||
var sort = false;
|
var sort = false;
|
||||||
var sortable = this.comparator && (at == null) && options.sort !== false;
|
var sortable = this.comparator && at == null && options.sort !== false;
|
||||||
var sortAttr = _.isString(this.comparator) ? this.comparator : null;
|
var sortAttr = _.isString(this.comparator) ? this.comparator : null;
|
||||||
|
|
||||||
// Turn bare objects into model references, and prevent invalid models
|
// Turn bare objects into model references, and prevent invalid models
|
||||||
// from being added.
|
// from being added.
|
||||||
var model;
|
var model, i;
|
||||||
for (var i = 0; i < models.length; i++) {
|
for (i = 0; i < models.length; i++) {
|
||||||
model = models[i];
|
model = models[i];
|
||||||
|
|
||||||
// If a duplicate is found, prevent it from being added and
|
// If a duplicate is found, prevent it from being added and
|
||||||
|
@ -857,6 +866,7 @@
|
||||||
var attrs = this._isModel(model) ? model.attributes : model;
|
var attrs = this._isModel(model) ? model.attributes : model;
|
||||||
if (options.parse) attrs = existing.parse(attrs, options);
|
if (options.parse) attrs = existing.parse(attrs, options);
|
||||||
existing.set(attrs, options);
|
existing.set(attrs, options);
|
||||||
|
toMerge.push(existing);
|
||||||
if (sortable && !sort) sort = existing.hasChanged(sortAttr);
|
if (sortable && !sort) sort = existing.hasChanged(sortAttr);
|
||||||
}
|
}
|
||||||
if (!modelMap[existing.cid]) {
|
if (!modelMap[existing.cid]) {
|
||||||
|
@ -890,8 +900,8 @@
|
||||||
var orderChanged = false;
|
var orderChanged = false;
|
||||||
var replace = !sortable && add && remove;
|
var replace = !sortable && add && remove;
|
||||||
if (set.length && replace) {
|
if (set.length && replace) {
|
||||||
orderChanged = this.length != set.length || _.some(this.models, function(model, index) {
|
orderChanged = this.length !== set.length || _.some(this.models, function(m, index) {
|
||||||
return model !== set[index];
|
return m !== set[index];
|
||||||
});
|
});
|
||||||
this.models.length = 0;
|
this.models.length = 0;
|
||||||
splice(this.models, set, 0);
|
splice(this.models, set, 0);
|
||||||
|
@ -905,7 +915,7 @@
|
||||||
// Silently sort the collection if appropriate.
|
// Silently sort the collection if appropriate.
|
||||||
if (sort) this.sort({silent: true});
|
if (sort) this.sort({silent: true});
|
||||||
|
|
||||||
// Unless silenced, it's time to fire all appropriate add/sort events.
|
// Unless silenced, it's time to fire all appropriate add/sort/update events.
|
||||||
if (!options.silent) {
|
if (!options.silent) {
|
||||||
for (i = 0; i < toAdd.length; i++) {
|
for (i = 0; i < toAdd.length; i++) {
|
||||||
if (at != null) options.index = at + i;
|
if (at != null) options.index = at + i;
|
||||||
|
@ -913,7 +923,14 @@
|
||||||
model.trigger('add', model, this, options);
|
model.trigger('add', model, this, options);
|
||||||
}
|
}
|
||||||
if (sort || orderChanged) this.trigger('sort', this, options);
|
if (sort || orderChanged) this.trigger('sort', this, options);
|
||||||
if (toAdd.length || toRemove.length) this.trigger('update', this, options);
|
if (toAdd.length || toRemove.length || toMerge.length) {
|
||||||
|
options.changes = {
|
||||||
|
added: toAdd,
|
||||||
|
removed: toRemove,
|
||||||
|
merged: toMerge
|
||||||
|
};
|
||||||
|
this.trigger('update', this, options);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the added (or merged) model (or models).
|
// Return the added (or merged) model (or models).
|
||||||
|
@ -963,11 +980,18 @@
|
||||||
return slice.apply(this.models, arguments);
|
return slice.apply(this.models, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Get a model from the set by id.
|
// Get a model from the set by id, cid, model object with id or cid
|
||||||
|
// properties, or an attributes object that is transformed through modelId.
|
||||||
get: function(obj) {
|
get: function(obj) {
|
||||||
if (obj == null) return void 0;
|
if (obj == null) return void 0;
|
||||||
var id = this.modelId(this._isModel(obj) ? obj.attributes : obj);
|
return this._byId[obj] ||
|
||||||
return this._byId[obj] || this._byId[id] || this._byId[obj.cid];
|
this._byId[this.modelId(obj.attributes || obj)] ||
|
||||||
|
obj.cid && this._byId[obj.cid];
|
||||||
|
},
|
||||||
|
|
||||||
|
// Returns `true` if the model is in the collection.
|
||||||
|
has: function(obj) {
|
||||||
|
return this.get(obj) != null;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Get the model at the given index.
|
// Get the model at the given index.
|
||||||
|
@ -1011,7 +1035,7 @@
|
||||||
|
|
||||||
// Pluck an attribute from each model in the collection.
|
// Pluck an attribute from each model in the collection.
|
||||||
pluck: function(attr) {
|
pluck: function(attr) {
|
||||||
return _.invoke(this.models, 'get', attr);
|
return this.map(attr + '');
|
||||||
},
|
},
|
||||||
|
|
||||||
// Fetch the default set of models for this collection, resetting the
|
// Fetch the default set of models for this collection, resetting the
|
||||||
|
@ -1042,9 +1066,9 @@
|
||||||
if (!wait) this.add(model, options);
|
if (!wait) this.add(model, options);
|
||||||
var collection = this;
|
var collection = this;
|
||||||
var success = options.success;
|
var success = options.success;
|
||||||
options.success = function(model, resp, callbackOpts) {
|
options.success = function(m, resp, callbackOpts) {
|
||||||
if (wait) collection.add(model, callbackOpts);
|
if (wait) collection.add(m, callbackOpts);
|
||||||
if (success) success.call(callbackOpts.context, model, resp, callbackOpts);
|
if (success) success.call(callbackOpts.context, m, resp, callbackOpts);
|
||||||
};
|
};
|
||||||
model.save(null, options);
|
model.save(null, options);
|
||||||
return model;
|
return model;
|
||||||
|
@ -1103,6 +1127,12 @@
|
||||||
this.models.splice(index, 1);
|
this.models.splice(index, 1);
|
||||||
this.length--;
|
this.length--;
|
||||||
|
|
||||||
|
// Remove references before triggering 'remove' event to prevent an
|
||||||
|
// infinite loop. #3693
|
||||||
|
delete this._byId[model.cid];
|
||||||
|
var id = this.modelId(model.attributes);
|
||||||
|
if (id != null) delete this._byId[id];
|
||||||
|
|
||||||
if (!options.silent) {
|
if (!options.silent) {
|
||||||
options.index = index;
|
options.index = index;
|
||||||
model.trigger('remove', model, this, options);
|
model.trigger('remove', model, this, options);
|
||||||
|
@ -1111,7 +1141,7 @@
|
||||||
removed.push(model);
|
removed.push(model);
|
||||||
this._removeReference(model, options);
|
this._removeReference(model, options);
|
||||||
}
|
}
|
||||||
return removed.length ? removed : false;
|
return removed;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Method for checking whether an object should be considered a model for
|
// Method for checking whether an object should be considered a model for
|
||||||
|
@ -1142,6 +1172,7 @@
|
||||||
// events simply proxy through. "add" and "remove" events that originate
|
// events simply proxy through. "add" and "remove" events that originate
|
||||||
// in other collections are ignored.
|
// in other collections are ignored.
|
||||||
_onModelEvent: function(event, model, collection, options) {
|
_onModelEvent: function(event, model, collection, options) {
|
||||||
|
if (model) {
|
||||||
if ((event === 'add' || event === 'remove') && collection !== this) return;
|
if ((event === 'add' || event === 'remove') && collection !== this) return;
|
||||||
if (event === 'destroy') this.remove(model, options);
|
if (event === 'destroy') this.remove(model, options);
|
||||||
if (event === 'change') {
|
if (event === 'change') {
|
||||||
|
@ -1152,6 +1183,7 @@
|
||||||
if (id != null) this._byId[id] = model;
|
if (id != null) this._byId[id] = model;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
this.trigger.apply(this, arguments);
|
this.trigger.apply(this, arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1160,14 +1192,14 @@
|
||||||
// Underscore methods that we want to implement on the Collection.
|
// Underscore methods that we want to implement on the Collection.
|
||||||
// 90% of the core usefulness of Backbone Collections is actually implemented
|
// 90% of the core usefulness of Backbone Collections is actually implemented
|
||||||
// right here:
|
// right here:
|
||||||
var collectionMethods = { forEach: 3, each: 3, map: 3, collect: 3, reduce: 4,
|
var collectionMethods = {forEach: 3, each: 3, map: 3, collect: 3, reduce: 0,
|
||||||
foldl: 4, inject: 4, reduceRight: 4, foldr: 4, find: 3, detect: 3, filter: 3,
|
foldl: 0, inject: 0, reduceRight: 0, foldr: 0, find: 3, detect: 3, filter: 3,
|
||||||
select: 3, reject: 3, every: 3, all: 3, some: 3, any: 3, include: 3, includes: 3,
|
select: 3, reject: 3, every: 3, all: 3, some: 3, any: 3, include: 3, includes: 3,
|
||||||
contains: 3, invoke: 0, max: 3, min: 3, toArray: 1, size: 1, first: 3,
|
contains: 3, invoke: 0, max: 3, min: 3, toArray: 1, size: 1, first: 3,
|
||||||
head: 3, take: 3, initial: 3, rest: 3, tail: 3, drop: 3, last: 3,
|
head: 3, take: 3, initial: 3, rest: 3, tail: 3, drop: 3, last: 3,
|
||||||
without: 0, difference: 0, indexOf: 3, shuffle: 1, lastIndexOf: 3,
|
without: 0, difference: 0, indexOf: 3, shuffle: 1, lastIndexOf: 3,
|
||||||
isEmpty: 1, chain: 1, sample: 3, partition: 3, groupBy: 3, countBy: 3,
|
isEmpty: 1, chain: 1, sample: 3, partition: 3, groupBy: 3, countBy: 3,
|
||||||
sortBy: 3, indexBy: 3};
|
sortBy: 3, indexBy: 3, findIndex: 3, findLastIndex: 3};
|
||||||
|
|
||||||
// Mix in each Underscore method as a proxy to `Collection#models`.
|
// Mix in each Underscore method as a proxy to `Collection#models`.
|
||||||
addUnderscoreMethods(Collection, collectionMethods, 'models');
|
addUnderscoreMethods(Collection, collectionMethods, 'models');
|
||||||
|
@ -1576,8 +1608,8 @@
|
||||||
// Does the pathname match the root?
|
// Does the pathname match the root?
|
||||||
matchRoot: function() {
|
matchRoot: function() {
|
||||||
var path = this.decodeFragment(this.location.pathname);
|
var path = this.decodeFragment(this.location.pathname);
|
||||||
var root = path.slice(0, this.root.length - 1) + '/';
|
var rootPath = path.slice(0, this.root.length - 1) + '/';
|
||||||
return root === this.root;
|
return rootPath === this.root;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Unicode characters in `location.pathname` are percent encoded so they're
|
// Unicode characters in `location.pathname` are percent encoded so they're
|
||||||
|
@ -1649,8 +1681,8 @@
|
||||||
// If we've started off with a route from a `pushState`-enabled
|
// If we've started off with a route from a `pushState`-enabled
|
||||||
// browser, but we're currently in a browser that doesn't support it...
|
// browser, but we're currently in a browser that doesn't support it...
|
||||||
if (!this._hasPushState && !this.atRoot()) {
|
if (!this._hasPushState && !this.atRoot()) {
|
||||||
var root = this.root.slice(0, -1) || '/';
|
var rootPath = this.root.slice(0, -1) || '/';
|
||||||
this.location.replace(root + '#' + this.getPath());
|
this.location.replace(rootPath + '#' + this.getPath());
|
||||||
// Return immediately as browser will do redirect to new url
|
// Return immediately as browser will do redirect to new url
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -1774,11 +1806,11 @@
|
||||||
fragment = this.getFragment(fragment || '');
|
fragment = this.getFragment(fragment || '');
|
||||||
|
|
||||||
// Don't include a trailing slash on the root.
|
// Don't include a trailing slash on the root.
|
||||||
var root = this.root;
|
var rootPath = this.root;
|
||||||
if (fragment === '' || fragment.charAt(0) === '?') {
|
if (fragment === '' || fragment.charAt(0) === '?') {
|
||||||
root = root.slice(0, -1) || '/';
|
rootPath = rootPath.slice(0, -1) || '/';
|
||||||
}
|
}
|
||||||
var url = root + fragment;
|
var url = rootPath + fragment;
|
||||||
|
|
||||||
// Strip the hash and decode for matching.
|
// Strip the hash and decode for matching.
|
||||||
fragment = this.decodeFragment(fragment.replace(pathStripper, ''));
|
fragment = this.decodeFragment(fragment.replace(pathStripper, ''));
|
||||||
|
@ -1794,7 +1826,7 @@
|
||||||
// fragment to store history.
|
// fragment to store history.
|
||||||
} else if (this._wantsHashChange) {
|
} else if (this._wantsHashChange) {
|
||||||
this._updateHash(this.location, fragment, options.replace);
|
this._updateHash(this.location, fragment, options.replace);
|
||||||
if (this.iframe && (fragment !== this.getHash(this.iframe.contentWindow))) {
|
if (this.iframe && fragment !== this.getHash(this.iframe.contentWindow)) {
|
||||||
var iWindow = this.iframe.contentWindow;
|
var iWindow = this.iframe.contentWindow;
|
||||||
|
|
||||||
// Opening and closing the iframe tricks IE7 and earlier to push a
|
// Opening and closing the iframe tricks IE7 and earlier to push a
|
||||||
|
@ -1856,14 +1888,9 @@
|
||||||
_.extend(child, parent, staticProps);
|
_.extend(child, parent, staticProps);
|
||||||
|
|
||||||
// Set the prototype chain to inherit from `parent`, without calling
|
// Set the prototype chain to inherit from `parent`, without calling
|
||||||
// `parent` constructor function.
|
// `parent`'s constructor function and add the prototype properties.
|
||||||
var Surrogate = function(){ this.constructor = child; };
|
child.prototype = _.create(parent.prototype, protoProps);
|
||||||
Surrogate.prototype = parent.prototype;
|
child.prototype.constructor = child;
|
||||||
child.prototype = new Surrogate;
|
|
||||||
|
|
||||||
// Add prototype properties (instance properties) to the subclass,
|
|
||||||
// if supplied.
|
|
||||||
if (protoProps) _.extend(child.prototype, protoProps);
|
|
||||||
|
|
||||||
// Set a convenience property in case the parent's prototype is needed
|
// Set a convenience property in case the parent's prototype is needed
|
||||||
// later.
|
// later.
|
||||||
|
@ -1890,5 +1917,4 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
return Backbone;
|
return Backbone;
|
||||||
|
});
|
||||||
}));
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,15 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group dependencies
|
||||||
|
* @group scripts
|
||||||
|
*/
|
||||||
|
class Tests_Dependencies_Backbonejs extends WP_UnitTestCase {
|
||||||
|
|
||||||
|
function test_exclusion_of_sourcemaps() {
|
||||||
|
$file = ABSPATH . WPINC . '/js/backbone.min.js';
|
||||||
|
$this->assertTrue( file_exists( $file ) );
|
||||||
|
$contents = trim( file_get_contents( $file ) );
|
||||||
|
$this->assertFalse( strpos( $contents, 'sourceMappingURL' ), 'Presence of sourceMappingURL' );
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue