Commit 038fc12d authored by Pascal Hartig's avatar Pascal Hartig

Flight: Upgrade transient dependencies

parent 3ed634b9
// Copyright 2009-2012 by contributors, MIT License // Copyright 2009-2012 by contributors, MIT License
// vim: ts=4 sts=4 sw=4 expandtab // vim: ts=4 sts=4 sw=4 expandtab
//Add semicolon to prevent IIFE from being passed as argument to concated code.
;
// Module systems magic dance // Module systems magic dance
(function (definition) { (function (definition) {
// RequireJS // RequireJS
...@@ -15,10 +17,28 @@ ...@@ -15,10 +17,28 @@
} }
})(function () { })(function () {
var call = Function.prototype.call;
var prototypeOfObject = Object.prototype;
var owns = call.bind(prototypeOfObject.hasOwnProperty);
// If JS engine supports accessors creating shortcuts.
var defineGetter;
var defineSetter;
var lookupGetter;
var lookupSetter;
var supportsAccessors;
if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
defineGetter = call.bind(prototypeOfObject.__defineGetter__);
defineSetter = call.bind(prototypeOfObject.__defineSetter__);
lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
}
// ES5 15.2.3.2 // ES5 15.2.3.2
// http://es5.github.com/#x15.2.3.2 // http://es5.github.com/#x15.2.3.2
if (!Object.getPrototypeOf) { if (!Object.getPrototypeOf) {
// https://github.com/kriskowal/es5-shim/issues#issue/2 // https://github.com/es-shims/es5-shim/issues#issue/2
// http://ejohn.org/blog/objectgetprototypeof/ // http://ejohn.org/blog/objectgetprototypeof/
// recommended by fschaefer on github // recommended by fschaefer on github
Object.getPrototypeOf = function getPrototypeOf(object) { Object.getPrototypeOf = function getPrototypeOf(object) {
...@@ -30,15 +50,53 @@ if (!Object.getPrototypeOf) { ...@@ -30,15 +50,53 @@ if (!Object.getPrototypeOf) {
}; };
} }
// ES5 15.2.3.3 //ES5 15.2.3.3
// http://es5.github.com/#x15.2.3.3 //http://es5.github.com/#x15.2.3.3
if (!Object.getOwnPropertyDescriptor) {
function doesGetOwnPropertyDescriptorWork(object) {
try {
object.sentinel = 0;
return Object.getOwnPropertyDescriptor(
object,
"sentinel"
).value === 0;
} catch (exception) {
// returns falsy
}
}
//check whether getOwnPropertyDescriptor works if it's given. Otherwise,
//shim partially.
if (Object.defineProperty) {
var getOwnPropertyDescriptorWorksOnObject =
doesGetOwnPropertyDescriptorWork({});
var getOwnPropertyDescriptorWorksOnDom = typeof document == "undefined" ||
doesGetOwnPropertyDescriptorWork(document.createElement("div"));
if (!getOwnPropertyDescriptorWorksOnDom ||
!getOwnPropertyDescriptorWorksOnObject
) {
var getOwnPropertyDescriptorFallback = Object.getOwnPropertyDescriptor;
}
}
if (!Object.getOwnPropertyDescriptor || getOwnPropertyDescriptorFallback) {
var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a non-object: "; var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a non-object: ";
Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) { Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
if ((typeof object != "object" && typeof object != "function") || object === null) { if ((typeof object != "object" && typeof object != "function") || object === null) {
throw new TypeError(ERR_NON_OBJECT + object); throw new TypeError(ERR_NON_OBJECT + object);
} }
// make a valiant attempt to use the real getOwnPropertyDescriptor
// for I8's DOM elements.
if (getOwnPropertyDescriptorFallback) {
try {
return getOwnPropertyDescriptorFallback.call(Object, object, property);
} catch (exception) {
// try the shim if the real one doesn't work
}
}
// If object does not owns property return undefined immediately. // If object does not owns property return undefined immediately.
if (!owns(object, property)) { if (!owns(object, property)) {
return; return;
...@@ -81,6 +139,7 @@ if (!Object.getOwnPropertyDescriptor) { ...@@ -81,6 +139,7 @@ if (!Object.getOwnPropertyDescriptor) {
// If we got this far we know that object has an own property that is // If we got this far we know that object has an own property that is
// not an accessor so we set it as a value and return descriptor. // not an accessor so we set it as a value and return descriptor.
descriptor.value = object[property]; descriptor.value = object[property];
descriptor.writable = true;
return descriptor; return descriptor;
}; };
} }
...@@ -96,15 +155,64 @@ if (!Object.getOwnPropertyNames) { ...@@ -96,15 +155,64 @@ if (!Object.getOwnPropertyNames) {
// ES5 15.2.3.5 // ES5 15.2.3.5
// http://es5.github.com/#x15.2.3.5 // http://es5.github.com/#x15.2.3.5
if (!Object.create) { if (!Object.create) {
// Contributed by Brandon Benvie, October, 2012
var createEmpty;
var supportsProto = Object.prototype.__proto__ === null;
if (supportsProto || typeof document == 'undefined') {
createEmpty = function () {
return { "__proto__": null };
};
} else {
// In old IE __proto__ can't be used to manually set `null`, nor does
// any other method exist to make an object that inherits from nothing,
// aside from Object.prototype itself. Instead, create a new global
// object and *steal* its Object.prototype and strip it bare. This is
// used as the prototype to create nullary objects.
createEmpty = function () {
var iframe = document.createElement('iframe');
var parent = document.body || document.documentElement;
iframe.style.display = 'none';
parent.appendChild(iframe);
iframe.src = 'javascript:';
var empty = iframe.contentWindow.Object.prototype;
parent.removeChild(iframe);
iframe = null;
delete empty.constructor;
delete empty.hasOwnProperty;
delete empty.propertyIsEnumerable;
delete empty.isPrototypeOf;
delete empty.toLocaleString;
delete empty.toString;
delete empty.valueOf;
empty.__proto__ = null;
function Empty() {}
Empty.prototype = empty;
// short-circuit future calls
createEmpty = function () {
return new Empty();
};
return new Empty();
};
}
Object.create = function create(prototype, properties) { Object.create = function create(prototype, properties) {
var object; var object;
function Type() {} // An empty constructor.
if (prototype === null) { if (prototype === null) {
object = { "__proto__": null }; object = createEmpty();
} else { } else {
if (typeof prototype != "object") { if (typeof prototype !== "object" && typeof prototype !== "function") {
throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'"); // In the native implementation `parent` can be `null`
// OR *any* `instanceof Object` (Object|Function|Array|RegExp|etc)
// Use `typeof` tho, b/c in old IE, DOM elements are not `instanceof Object`
// like they are in modern browsers. Using `Object.create` on DOM elements
// is...err...probably inappropriate, but the native version allows for it.
throw new TypeError("Object prototype may only be an Object or null"); // same msg as Chrome
} }
var Type = function () {};
Type.prototype = prototype; Type.prototype = prototype;
object = new Type(); object = new Type();
// IE has no built-in implementation of `Object.getPrototypeOf` // IE has no built-in implementation of `Object.getPrototypeOf`
...@@ -113,9 +221,11 @@ if (!Object.create) { ...@@ -113,9 +221,11 @@ if (!Object.create) {
// objects created using `Object.create` // objects created using `Object.create`
object.__proto__ = prototype; object.__proto__ = prototype;
} }
if (properties !== void 0) { if (properties !== void 0) {
Object.defineProperties(object, properties); Object.defineProperties(object, properties);
} }
return object; return object;
}; };
} }
...@@ -125,7 +235,7 @@ if (!Object.create) { ...@@ -125,7 +235,7 @@ if (!Object.create) {
// Patch for WebKit and IE8 standard mode // Patch for WebKit and IE8 standard mode
// Designed by hax <hax.github.com> // Designed by hax <hax.github.com>
// related issue: https://github.com/kriskowal/es5-shim/issues#issue/5 // related issue: https://github.com/es-shims/es5-shim/issues#issue/5
// IE8 Reference: // IE8 Reference:
// http://msdn.microsoft.com/en-us/library/dd282900.aspx // http://msdn.microsoft.com/en-us/library/dd282900.aspx
// http://msdn.microsoft.com/en-us/library/dd229916.aspx // http://msdn.microsoft.com/en-us/library/dd229916.aspx
...@@ -148,7 +258,8 @@ if (Object.defineProperty) { ...@@ -148,7 +258,8 @@ if (Object.defineProperty) {
var definePropertyWorksOnDom = typeof document == "undefined" || var definePropertyWorksOnDom = typeof document == "undefined" ||
doesDefinePropertyWork(document.createElement("div")); doesDefinePropertyWork(document.createElement("div"));
if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) { if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
var definePropertyFallback = Object.defineProperty; var definePropertyFallback = Object.defineProperty,
definePropertiesFallback = Object.defineProperties;
} }
} }
...@@ -228,8 +339,17 @@ if (!Object.defineProperty || definePropertyFallback) { ...@@ -228,8 +339,17 @@ if (!Object.defineProperty || definePropertyFallback) {
// ES5 15.2.3.7 // ES5 15.2.3.7
// http://es5.github.com/#x15.2.3.7 // http://es5.github.com/#x15.2.3.7
if (!Object.defineProperties) { if (!Object.defineProperties || definePropertiesFallback) {
Object.defineProperties = function defineProperties(object, properties) { Object.defineProperties = function defineProperties(object, properties) {
// make a valiant attempt to use the real defineProperties
if (definePropertiesFallback) {
try {
return definePropertiesFallback.call(Object, object, properties);
} catch (exception) {
// try the shim if the real one doesn't work
}
}
for (var property in properties) { for (var property in properties) {
if (owns(properties, property) && property != "__proto__") { if (owns(properties, property) && property != "__proto__") {
Object.defineProperty(object, property, properties[property]); Object.defineProperty(object, property, properties[property]);
......
// Copyright 2009-2012 by contributors, MIT License // Copyright 2009-2012 by contributors, MIT License
// vim: ts=4 sts=4 sw=4 expandtab // vim: ts=4 sts=4 sw=4 expandtab
//Add semicolon to prevent IIFE from being passed as argument to concated code.
;
// Module systems magic dance // Module systems magic dance
(function (definition) { (function (definition) {
// RequireJS // RequireJS
...@@ -24,6 +26,20 @@ ...@@ -24,6 +26,20 @@
* Required reading: http://javascriptweblog.wordpress.com/2011/12/05/extending-javascript-natives/ * Required reading: http://javascriptweblog.wordpress.com/2011/12/05/extending-javascript-natives/
*/ */
// ES-5 15.1.2.2
if (parseInt('08') !== 8) {
parseInt = (function (origParseInt) {
var hexRegex = /^0[xX]/;
return function parseIntES5(str, radix) {
str = String(str).trim();
if (!+radix) {
radix = hexRegex.test(str) ? 16 : 10;
}
return origParseInt(str, radix);
};
}(parseInt));
}
// //
// Function // Function
// ======== // ========
...@@ -32,6 +48,8 @@ ...@@ -32,6 +48,8 @@
// ES-5 15.3.4.5 // ES-5 15.3.4.5
// http://es5.github.com/#x15.3.4.5 // http://es5.github.com/#x15.3.4.5
function Empty() {}
if (!Function.prototype.bind) { if (!Function.prototype.bind) {
Function.prototype.bind = function bind(that) { // .length is 1 Function.prototype.bind = function bind(that) { // .length is 1
// 1. Let Target be the this value. // 1. Let Target be the this value.
...@@ -43,7 +61,7 @@ if (!Function.prototype.bind) { ...@@ -43,7 +61,7 @@ if (!Function.prototype.bind) {
// 3. Let A be a new (possibly empty) internal list of all of the // 3. Let A be a new (possibly empty) internal list of all of the
// argument values provided after thisArg (arg1, arg2 etc), in order. // argument values provided after thisArg (arg1, arg2 etc), in order.
// XXX slicedArgs will stand in for "A" if used // XXX slicedArgs will stand in for "A" if used
var args = slice.call(arguments, 1); // for normal call var args = _Array_slice_.call(arguments, 1); // for normal call
// 4. Let F be a new native ECMAScript object. // 4. Let F be a new native ECMAScript object.
// 11. Set the [[Prototype]] internal property of F to the standard // 11. Set the [[Prototype]] internal property of F to the standard
// built-in Function prototype object as specified in 15.3.3.1. // built-in Function prototype object as specified in 15.3.3.1.
...@@ -53,7 +71,7 @@ if (!Function.prototype.bind) { ...@@ -53,7 +71,7 @@ if (!Function.prototype.bind) {
// 15.3.4.5.2. // 15.3.4.5.2.
// 14. Set the [[HasInstance]] internal property of F as described in // 14. Set the [[HasInstance]] internal property of F as described in
// 15.3.4.5.3. // 15.3.4.5.3.
var bound = function () { var binder = function () {
if (this instanceof bound) { if (this instanceof bound) {
// 15.3.4.5.2 [[Construct]] // 15.3.4.5.2 [[Construct]]
...@@ -72,18 +90,14 @@ if (!Function.prototype.bind) { ...@@ -72,18 +90,14 @@ if (!Function.prototype.bind) {
// 5. Return the result of calling the [[Construct]] internal // 5. Return the result of calling the [[Construct]] internal
// method of target providing args as the arguments. // method of target providing args as the arguments.
var F = function(){};
F.prototype = target.prototype;
var self = new F;
var result = target.apply( var result = target.apply(
self, this,
args.concat(slice.call(arguments)) args.concat(_Array_slice_.call(arguments))
); );
if (Object(result) === result) { if (Object(result) === result) {
return result; return result;
} }
return self; return this;
} else { } else {
// 15.3.4.5.1 [[Call]] // 15.3.4.5.1 [[Call]]
...@@ -107,21 +121,42 @@ if (!Function.prototype.bind) { ...@@ -107,21 +121,42 @@ if (!Function.prototype.bind) {
// equiv: target.call(this, ...boundArgs, ...args) // equiv: target.call(this, ...boundArgs, ...args)
return target.apply( return target.apply(
that, that,
args.concat(slice.call(arguments)) args.concat(_Array_slice_.call(arguments))
); );
} }
}; };
// XXX bound.length is never writable, so don't even try
//
// 15. If the [[Class]] internal property of Target is "Function", then // 15. If the [[Class]] internal property of Target is "Function", then
// a. Let L be the length property of Target minus the length of A. // a. Let L be the length property of Target minus the length of A.
// b. Set the length own property of F to either 0 or L, whichever is // b. Set the length own property of F to either 0 or L, whichever is
// larger. // larger.
// 16. Else set the length own property of F to 0. // 16. Else set the length own property of F to 0.
var boundLength = Math.max(0, target.length - args.length);
// 17. Set the attributes of the length own property of F to the values // 17. Set the attributes of the length own property of F to the values
// specified in 15.3.5.1. // specified in 15.3.5.1.
var boundArgs = [];
for (var i = 0; i < boundLength; i++) {
boundArgs.push("$" + i);
}
// XXX Build a dynamic function with desired amount of arguments is the only
// way to set the length property of a function.
// In environments where Content Security Policies enabled (Chrome extensions,
// for ex.) all use of eval or Function costructor throws an exception.
// However in all of these environments Function.prototype.bind exists
// and so this code will never be executed.
var bound = Function("binder", "return function(" + boundArgs.join(",") + "){return binder.apply(this,arguments)}")(binder);
if (target.prototype) {
Empty.prototype = target.prototype;
bound.prototype = new Empty();
// Clean up dangling references.
Empty.prototype = null;
}
// TODO // TODO
// 18. Set the [[Extensible]] internal property of F to true. // 18. Set the [[Extensible]] internal property of F to true.
...@@ -155,7 +190,7 @@ if (!Function.prototype.bind) { ...@@ -155,7 +190,7 @@ if (!Function.prototype.bind) {
var call = Function.prototype.call; var call = Function.prototype.call;
var prototypeOfArray = Array.prototype; var prototypeOfArray = Array.prototype;
var prototypeOfObject = Object.prototype; var prototypeOfObject = Object.prototype;
var slice = prototypeOfArray.slice; var _Array_slice_ = prototypeOfArray.slice;
// Having a toString local variable name breaks in Opera so use _toString. // Having a toString local variable name breaks in Opera so use _toString.
var _toString = call.bind(prototypeOfObject.toString); var _toString = call.bind(prototypeOfObject.toString);
var owns = call.bind(prototypeOfObject.hasOwnProperty); var owns = call.bind(prototypeOfObject.hasOwnProperty);
...@@ -178,6 +213,116 @@ if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) { ...@@ -178,6 +213,116 @@ if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
// ===== // =====
// //
// ES5 15.4.4.12
// http://es5.github.com/#x15.4.4.12
// Default value for second param
// [bugfix, ielt9, old browsers]
// IE < 9 bug: [1,2].splice(0).join("") == "" but should be "12"
if ([1,2].splice(0).length != 2) {
var array_splice = Array.prototype.splice;
var array_push = Array.prototype.push;
var array_unshift = Array.prototype.unshift;
if (function() { // test IE < 9 to splice bug - see issue #138
function makeArray(l) {
var a = [];
while (l--) {
a.unshift(l)
}
return a
}
var array = []
, lengthBefore
;
array.splice.bind(array, 0, 0).apply(null, makeArray(20));
array.splice.bind(array, 0, 0).apply(null, makeArray(26));
lengthBefore = array.length; //20
array.splice(5, 0, "XXX"); // add one element
if (lengthBefore + 1 == array.length) {
return true;// has right splice implementation without bugs
}
// else {
// IE8 bug
// }
}()) {//IE 6/7
Array.prototype.splice = function(start, deleteCount) {
if (!arguments.length) {
return [];
} else {
return array_splice.apply(this, [
start === void 0 ? 0 : start,
deleteCount === void 0 ? (this.length - start) : deleteCount
].concat(_Array_slice_.call(arguments, 2)))
}
};
}
else {//IE8
Array.prototype.splice = function(start, deleteCount) {
var result
, args = _Array_slice_.call(arguments, 2)
, addElementsCount = args.length
;
if (!arguments.length) {
return [];
}
if (start === void 0) { // default
start = 0;
}
if (deleteCount === void 0) { // default
deleteCount = this.length - start;
}
if (addElementsCount > 0) {
if (deleteCount <= 0) {
if (start == this.length) { // tiny optimisation #1
array_push.apply(this, args);
return [];
}
if (start == 0) { // tiny optimisation #2
array_unshift.apply(this, args);
return [];
}
}
// Array.prototype.splice implementation
result = _Array_slice_.call(this, start, start + deleteCount);// delete part
args.push.apply(args, _Array_slice_.call(this, start + deleteCount, this.length));// right part
args.unshift.apply(args, _Array_slice_.call(this, 0, start));// left part
// delete all items from this array and replace it to 'left part' + _Array_slice_.call(arguments, 2) + 'right part'
args.unshift(0, this.length);
array_splice.apply(this, args);
return result;
}
return array_splice.call(this, start, deleteCount);
}
}
}
// ES5 15.4.4.12
// http://es5.github.com/#x15.4.4.13
// Return len+argCount.
// [bugfix, ielt8]
// IE < 8 bug: [].unshift(0) == undefined but should be "1"
if ([].unshift(0) != 1) {
var array_unshift = Array.prototype.unshift;
Array.prototype.unshift = function() {
array_unshift.apply(this, arguments);
return this.length;
};
}
// ES5 15.4.3.2 // ES5 15.4.3.2
// http://es5.github.com/#x15.4.3.2 // http://es5.github.com/#x15.4.3.2
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray
...@@ -202,9 +347,25 @@ if (!Array.isArray) { ...@@ -202,9 +347,25 @@ if (!Array.isArray) {
// ES5 15.4.4.18 // ES5 15.4.4.18
// http://es5.github.com/#x15.4.4.18 // http://es5.github.com/#x15.4.4.18
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/forEach // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/forEach
if (!Array.prototype.forEach) {
// Check failure of by-index access of string characters (IE < 9)
// and failure of `0 in boxedString` (Rhino)
var boxedString = Object("a"),
splitString = boxedString[0] != "a" || !(0 in boxedString);
// Check node 0.6.21 bug where third parameter is not boxed
var boxedForEach = true;
if (Array.prototype.forEach) {
Array.prototype.forEach.call("foo", function(item, i, obj) {
if (typeof obj !== 'object') boxedForEach = false;
});
}
if (!Array.prototype.forEach || !boxedForEach) {
Array.prototype.forEach = function forEach(fun /*, thisp*/) { Array.prototype.forEach = function forEach(fun /*, thisp*/) {
var self = toObject(this), var object = toObject(this),
self = splitString && _toString(this) == "[object String]" ?
this.split("") :
object,
thisp = arguments[1], thisp = arguments[1],
i = -1, i = -1,
length = self.length >>> 0; length = self.length >>> 0;
...@@ -217,8 +378,9 @@ if (!Array.prototype.forEach) { ...@@ -217,8 +378,9 @@ if (!Array.prototype.forEach) {
while (++i < length) { while (++i < length) {
if (i in self) { if (i in self) {
// Invoke the callback function with call, passing arguments: // Invoke the callback function with call, passing arguments:
// context, property value, property key, thisArg object context // context, property value, property key, thisArg object
fun.call(thisp, self[i], i, self); // context
fun.call(thisp, self[i], i, object);
} }
} }
}; };
...@@ -229,7 +391,10 @@ if (!Array.prototype.forEach) { ...@@ -229,7 +391,10 @@ if (!Array.prototype.forEach) {
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/map
if (!Array.prototype.map) { if (!Array.prototype.map) {
Array.prototype.map = function map(fun /*, thisp*/) { Array.prototype.map = function map(fun /*, thisp*/) {
var self = toObject(this), var object = toObject(this),
self = splitString && _toString(this) == "[object String]" ?
this.split("") :
object,
length = self.length >>> 0, length = self.length >>> 0,
result = Array(length), result = Array(length),
thisp = arguments[1]; thisp = arguments[1];
...@@ -241,7 +406,7 @@ if (!Array.prototype.map) { ...@@ -241,7 +406,7 @@ if (!Array.prototype.map) {
for (var i = 0; i < length; i++) { for (var i = 0; i < length; i++) {
if (i in self) if (i in self)
result[i] = fun.call(thisp, self[i], i, self); result[i] = fun.call(thisp, self[i], i, object);
} }
return result; return result;
}; };
...@@ -252,7 +417,10 @@ if (!Array.prototype.map) { ...@@ -252,7 +417,10 @@ if (!Array.prototype.map) {
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/filter
if (!Array.prototype.filter) { if (!Array.prototype.filter) {
Array.prototype.filter = function filter(fun /*, thisp */) { Array.prototype.filter = function filter(fun /*, thisp */) {
var self = toObject(this), var object = toObject(this),
self = splitString && _toString(this) == "[object String]" ?
this.split("") :
object,
length = self.length >>> 0, length = self.length >>> 0,
result = [], result = [],
value, value,
...@@ -266,7 +434,7 @@ if (!Array.prototype.filter) { ...@@ -266,7 +434,7 @@ if (!Array.prototype.filter) {
for (var i = 0; i < length; i++) { for (var i = 0; i < length; i++) {
if (i in self) { if (i in self) {
value = self[i]; value = self[i];
if (fun.call(thisp, value, i, self)) { if (fun.call(thisp, value, i, object)) {
result.push(value); result.push(value);
} }
} }
...@@ -280,7 +448,10 @@ if (!Array.prototype.filter) { ...@@ -280,7 +448,10 @@ if (!Array.prototype.filter) {
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/every
if (!Array.prototype.every) { if (!Array.prototype.every) {
Array.prototype.every = function every(fun /*, thisp */) { Array.prototype.every = function every(fun /*, thisp */) {
var self = toObject(this), var object = toObject(this),
self = splitString && _toString(this) == "[object String]" ?
this.split("") :
object,
length = self.length >>> 0, length = self.length >>> 0,
thisp = arguments[1]; thisp = arguments[1];
...@@ -290,7 +461,7 @@ if (!Array.prototype.every) { ...@@ -290,7 +461,7 @@ if (!Array.prototype.every) {
} }
for (var i = 0; i < length; i++) { for (var i = 0; i < length; i++) {
if (i in self && !fun.call(thisp, self[i], i, self)) { if (i in self && !fun.call(thisp, self[i], i, object)) {
return false; return false;
} }
} }
...@@ -303,7 +474,10 @@ if (!Array.prototype.every) { ...@@ -303,7 +474,10 @@ if (!Array.prototype.every) {
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/some
if (!Array.prototype.some) { if (!Array.prototype.some) {
Array.prototype.some = function some(fun /*, thisp */) { Array.prototype.some = function some(fun /*, thisp */) {
var self = toObject(this), var object = toObject(this),
self = splitString && _toString(this) == "[object String]" ?
this.split("") :
object,
length = self.length >>> 0, length = self.length >>> 0,
thisp = arguments[1]; thisp = arguments[1];
...@@ -313,7 +487,7 @@ if (!Array.prototype.some) { ...@@ -313,7 +487,7 @@ if (!Array.prototype.some) {
} }
for (var i = 0; i < length; i++) { for (var i = 0; i < length; i++) {
if (i in self && fun.call(thisp, self[i], i, self)) { if (i in self && fun.call(thisp, self[i], i, object)) {
return true; return true;
} }
} }
...@@ -326,7 +500,10 @@ if (!Array.prototype.some) { ...@@ -326,7 +500,10 @@ if (!Array.prototype.some) {
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduce
if (!Array.prototype.reduce) { if (!Array.prototype.reduce) {
Array.prototype.reduce = function reduce(fun /*, initial*/) { Array.prototype.reduce = function reduce(fun /*, initial*/) {
var self = toObject(this), var object = toObject(this),
self = splitString && _toString(this) == "[object String]" ?
this.split("") :
object,
length = self.length >>> 0; length = self.length >>> 0;
// If no callback function or if callback is not a callable function // If no callback function or if callback is not a callable function
...@@ -336,7 +513,7 @@ if (!Array.prototype.reduce) { ...@@ -336,7 +513,7 @@ if (!Array.prototype.reduce) {
// no value to return if no initial value and an empty array // no value to return if no initial value and an empty array
if (!length && arguments.length == 1) { if (!length && arguments.length == 1) {
throw new TypeError('reduce of empty array with no initial value'); throw new TypeError("reduce of empty array with no initial value");
} }
var i = 0; var i = 0;
...@@ -352,14 +529,14 @@ if (!Array.prototype.reduce) { ...@@ -352,14 +529,14 @@ if (!Array.prototype.reduce) {
// if array contains no values, no initial value to return // if array contains no values, no initial value to return
if (++i >= length) { if (++i >= length) {
throw new TypeError('reduce of empty array with no initial value'); throw new TypeError("reduce of empty array with no initial value");
} }
} while (true); } while (true);
} }
for (; i < length; i++) { for (; i < length; i++) {
if (i in self) { if (i in self) {
result = fun.call(void 0, result, self[i], i, self); result = fun.call(void 0, result, self[i], i, object);
} }
} }
...@@ -372,7 +549,10 @@ if (!Array.prototype.reduce) { ...@@ -372,7 +549,10 @@ if (!Array.prototype.reduce) {
// https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight // https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Objects/Array/reduceRight
if (!Array.prototype.reduceRight) { if (!Array.prototype.reduceRight) {
Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) { Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
var self = toObject(this), var object = toObject(this),
self = splitString && _toString(this) == "[object String]" ?
this.split("") :
object,
length = self.length >>> 0; length = self.length >>> 0;
// If no callback function or if callback is not a callable function // If no callback function or if callback is not a callable function
...@@ -382,7 +562,7 @@ if (!Array.prototype.reduceRight) { ...@@ -382,7 +562,7 @@ if (!Array.prototype.reduceRight) {
// no value to return if no initial value, empty array // no value to return if no initial value, empty array
if (!length && arguments.length == 1) { if (!length && arguments.length == 1) {
throw new TypeError('reduceRight of empty array with no initial value'); throw new TypeError("reduceRight of empty array with no initial value");
} }
var result, i = length - 1; var result, i = length - 1;
...@@ -397,14 +577,18 @@ if (!Array.prototype.reduceRight) { ...@@ -397,14 +577,18 @@ if (!Array.prototype.reduceRight) {
// if array contains no values, no initial value to return // if array contains no values, no initial value to return
if (--i < 0) { if (--i < 0) {
throw new TypeError('reduceRight of empty array with no initial value'); throw new TypeError("reduceRight of empty array with no initial value");
} }
} while (true); } while (true);
} }
if (i < 0) {
return result;
}
do { do {
if (i in this) { if (i in this) {
result = fun.call(void 0, result, self[i], i, self); result = fun.call(void 0, result, self[i], i, object);
} }
} while (i--); } while (i--);
...@@ -415,9 +599,11 @@ if (!Array.prototype.reduceRight) { ...@@ -415,9 +599,11 @@ if (!Array.prototype.reduceRight) {
// ES5 15.4.4.14 // ES5 15.4.4.14
// http://es5.github.com/#x15.4.4.14 // http://es5.github.com/#x15.4.4.14
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/indexOf
if (!Array.prototype.indexOf) { if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) {
Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) { Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
var self = toObject(this), var self = splitString && _toString(this) == "[object String]" ?
this.split("") :
toObject(this),
length = self.length >>> 0; length = self.length >>> 0;
if (!length) { if (!length) {
...@@ -443,9 +629,11 @@ if (!Array.prototype.indexOf) { ...@@ -443,9 +629,11 @@ if (!Array.prototype.indexOf) {
// ES5 15.4.4.15 // ES5 15.4.4.15
// http://es5.github.com/#x15.4.4.15 // http://es5.github.com/#x15.4.4.15
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/lastIndexOf
if (!Array.prototype.lastIndexOf) { if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) {
Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) { Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
var self = toObject(this), var self = splitString && _toString(this) == "[object String]" ?
this.split("") :
toObject(this),
length = self.length >>> 0; length = self.length >>> 0;
if (!length) { if (!length) {
...@@ -493,7 +681,10 @@ if (!Object.keys) { ...@@ -493,7 +681,10 @@ if (!Object.keys) {
Object.keys = function keys(object) { Object.keys = function keys(object) {
if ((typeof object != "object" && typeof object != "function") || object === null) { if (
(typeof object != "object" && typeof object != "function") ||
object === null
) {
throw new TypeError("Object.keys called on a non-object"); throw new TypeError("Object.keys called on a non-object");
} }
...@@ -529,64 +720,96 @@ if (!Object.keys) { ...@@ -529,64 +720,96 @@ if (!Object.keys) {
// string format defined in 15.9.1.15. All fields are present in the String. // string format defined in 15.9.1.15. All fields are present in the String.
// The time zone is always UTC, denoted by the suffix Z. If the time value of // The time zone is always UTC, denoted by the suffix Z. If the time value of
// this object is not a finite Number a RangeError exception is thrown. // this object is not a finite Number a RangeError exception is thrown.
if (!Date.prototype.toISOString || (new Date(-62198755200000).toISOString().indexOf('-000001') === -1)) { var negativeDate = -62198755200000,
negativeYearString = "-000001";
if (
!Date.prototype.toISOString ||
(new Date(negativeDate).toISOString().indexOf(negativeYearString) === -1)
) {
Date.prototype.toISOString = function toISOString() { Date.prototype.toISOString = function toISOString() {
var result, length, value, year; var result, length, value, year, month;
if (!isFinite(this)) { if (!isFinite(this)) {
throw new RangeError("Date.prototype.toISOString called on non-finite value."); throw new RangeError("Date.prototype.toISOString called on non-finite value.");
} }
year = this.getUTCFullYear();
month = this.getUTCMonth();
// see https://github.com/es-shims/es5-shim/issues/111
year += Math.floor(month / 12);
month = (month % 12 + 12) % 12;
// the date time string format is specified in 15.9.1.15. // the date time string format is specified in 15.9.1.15.
result = [this.getUTCMonth() + 1, this.getUTCDate(), result = [month + 1, this.getUTCDate(),
this.getUTCHours(), this.getUTCMinutes(), this.getUTCSeconds()]; this.getUTCHours(), this.getUTCMinutes(), this.getUTCSeconds()];
year = this.getUTCFullYear(); year = (
year = (year < 0 ? '-' : (year > 9999 ? '+' : '')) + ('00000' + Math.abs(year)).slice(0 <= year && year <= 9999 ? -4 : -6); (year < 0 ? "-" : (year > 9999 ? "+" : "")) +
("00000" + Math.abs(year))
.slice(0 <= year && year <= 9999 ? -4 : -6)
);
length = result.length; length = result.length;
while (length--) { while (length--) {
value = result[length]; value = result[length];
// pad months, days, hours, minutes, and seconds to have two digits. // pad months, days, hours, minutes, and seconds to have two
// digits.
if (value < 10) { if (value < 10) {
result[length] = "0" + value; result[length] = "0" + value;
} }
} }
// pad milliseconds to have three digits. // pad milliseconds to have three digits.
return year + "-" + result.slice(0, 2).join("-") + "T" + result.slice(2).join(":") + "." + return (
("000" + this.getUTCMilliseconds()).slice(-3) + "Z"; year + "-" + result.slice(0, 2).join("-") +
} "T" + result.slice(2).join(":") + "." +
} ("000" + this.getUTCMilliseconds()).slice(-3) + "Z"
);
// ES5 15.9.4.4
// http://es5.github.com/#x15.9.4.4
if (!Date.now) {
Date.now = function now() {
return new Date().getTime();
}; };
} }
// ES5 15.9.5.44 // ES5 15.9.5.44
// http://es5.github.com/#x15.9.5.44 // http://es5.github.com/#x15.9.5.44
// This function provides a String representation of a Date object for use by // This function provides a String representation of a Date object for use by
// JSON.stringify (15.12.3). // JSON.stringify (15.12.3).
if (!Date.prototype.toJSON) { var dateToJSONIsSupported = false;
try {
dateToJSONIsSupported = (
Date.prototype.toJSON &&
new Date(NaN).toJSON() === null &&
new Date(negativeDate).toJSON().indexOf(negativeYearString) !== -1 &&
Date.prototype.toJSON.call({ // generic
toISOString: function () {
return true;
}
})
);
} catch (e) {
}
if (!dateToJSONIsSupported) {
Date.prototype.toJSON = function toJSON(key) { Date.prototype.toJSON = function toJSON(key) {
// When the toJSON method is called with argument key, the following // When the toJSON method is called with argument key, the following
// steps are taken: // steps are taken:
// 1. Let O be the result of calling ToObject, giving it the this // 1. Let O be the result of calling ToObject, giving it the this
// value as its argument. // value as its argument.
// 2. Let tv be ToPrimitive(O, hint Number). // 2. Let tv be toPrimitive(O, hint Number).
var o = Object(this),
tv = toPrimitive(o),
toISO;
// 3. If tv is a Number and is not finite, return null. // 3. If tv is a Number and is not finite, return null.
// XXX if (typeof tv === "number" && !isFinite(tv)) {
return null;
}
// 4. Let toISO be the result of calling the [[Get]] internal method of // 4. Let toISO be the result of calling the [[Get]] internal method of
// O with argument "toISOString". // O with argument "toISOString".
toISO = o.toISOString;
// 5. If IsCallable(toISO) is false, throw a TypeError exception. // 5. If IsCallable(toISO) is false, throw a TypeError exception.
if (typeof this.toISOString != "function") { if (typeof toISO != "function") {
throw new TypeError('toISOString property is not callable'); throw new TypeError("toISOString property is not callable");
} }
// 6. Return the result of calling the [[Call]] internal method of // 6. Return the result of calling the [[Call]] internal method of
// toISO with O as the this value and an empty argument list. // toISO with O as the this value and an empty argument list.
return this.toISOString(); return toISO.call(o);
// NOTE 1 The argument is ignored. // NOTE 1 The argument is ignored.
...@@ -603,13 +826,13 @@ if (!Date.prototype.toJSON) { ...@@ -603,13 +826,13 @@ if (!Date.prototype.toJSON) {
// http://es5.github.com/#x15.9.4.2 // http://es5.github.com/#x15.9.4.2
// based on work shared by Daniel Friesen (dantman) // based on work shared by Daniel Friesen (dantman)
// http://gist.github.com/303249 // http://gist.github.com/303249
if (!Date.parse || Date.parse("+275760-09-13T00:00:00.000Z") !== 8.64e15) { if (!Date.parse || "Date.parse is buggy") {
// XXX global assignment won't work in embeddings that use // XXX global assignment won't work in embeddings that use
// an alternate object for the context. // an alternate object for the context.
Date = (function(NativeDate) { Date = (function(NativeDate) {
// Date.length === 7 // Date.length === 7
var Date = function Date(Y, M, D, h, m, s, ms) { function Date(Y, M, D, h, m, s, ms) {
var length = arguments.length; var length = arguments.length;
if (this instanceof NativeDate) { if (this instanceof NativeDate) {
var date = length == 1 && String(Y) === Y ? // isString(Y) var date = length == 1 && String(Y) === Y ? // isString(Y)
...@@ -634,7 +857,8 @@ if (!Date.parse || Date.parse("+275760-09-13T00:00:00.000Z") !== 8.64e15) { ...@@ -634,7 +857,8 @@ if (!Date.parse || Date.parse("+275760-09-13T00:00:00.000Z") !== 8.64e15) {
// 15.9.1.15 Date Time String Format. // 15.9.1.15 Date Time String Format.
var isoDateExpression = new RegExp("^" + var isoDateExpression = new RegExp("^" +
"(\\d{4}|[\+\-]\\d{6})" + // four-digit year capture or sign + 6-digit extended year "(\\d{4}|[\+\-]\\d{6})" + // four-digit year capture or sign +
// 6-digit extended year
"(?:-(\\d{2})" + // optional month capture "(?:-(\\d{2})" + // optional month capture
"(?:-(\\d{2})" + // optional day capture "(?:-(\\d{2})" + // optional day capture
"(?:" + // capture hours:minutes:seconds.milliseconds "(?:" + // capture hours:minutes:seconds.milliseconds
...@@ -642,9 +866,9 @@ if (!Date.parse || Date.parse("+275760-09-13T00:00:00.000Z") !== 8.64e15) { ...@@ -642,9 +866,9 @@ if (!Date.parse || Date.parse("+275760-09-13T00:00:00.000Z") !== 8.64e15) {
":(\\d{2})" + // minutes capture ":(\\d{2})" + // minutes capture
"(?:" + // optional :seconds.milliseconds "(?:" + // optional :seconds.milliseconds
":(\\d{2})" + // seconds capture ":(\\d{2})" + // seconds capture
"(?:\\.(\\d{3}))?" + // milliseconds capture "(?:(\\.\\d{1,}))?" + // milliseconds capture
")?" + ")?" +
"(?:" + // capture UTC offset component "(" + // capture UTC offset component
"Z|" + // UTC capture "Z|" + // UTC capture
"(?:" + // offset specifier +/-hours:minutes "(?:" + // offset specifier +/-hours:minutes
"([-+])" + // sign capture "([-+])" + // sign capture
...@@ -654,6 +878,25 @@ if (!Date.parse || Date.parse("+275760-09-13T00:00:00.000Z") !== 8.64e15) { ...@@ -654,6 +878,25 @@ if (!Date.parse || Date.parse("+275760-09-13T00:00:00.000Z") !== 8.64e15) {
")?)?)?)?" + ")?)?)?)?" +
"$"); "$");
var months = [
0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365
];
function dayFromMonth(year, month) {
var t = month > 1 ? 1 : 0;
return (
months[month] +
Math.floor((year - 1969 + t) / 4) -
Math.floor((year - 1901 + t) / 100) +
Math.floor((year - 1601 + t) / 400) +
365 * (year - 1970)
);
}
function toUTC(t) {
return Number(new NativeDate(1970, 0, 1, 0, 0, 0, t));
}
// Copy any custom methods a 3rd party library may have added // Copy any custom methods a 3rd party library may have added
for (var key in NativeDate) { for (var key in NativeDate) {
Date[key] = NativeDate[key]; Date[key] = NativeDate[key];
...@@ -669,60 +912,369 @@ if (!Date.parse || Date.parse("+275760-09-13T00:00:00.000Z") !== 8.64e15) { ...@@ -669,60 +912,369 @@ if (!Date.parse || Date.parse("+275760-09-13T00:00:00.000Z") !== 8.64e15) {
Date.parse = function parse(string) { Date.parse = function parse(string) {
var match = isoDateExpression.exec(string); var match = isoDateExpression.exec(string);
if (match) { if (match) {
match.shift(); // kill match[0], the full match
// parse months, days, hours, minutes, seconds, and milliseconds // parse months, days, hours, minutes, seconds, and milliseconds
for (var i = 1; i < 7; i++) {
// provide default values if necessary // provide default values if necessary
match[i] = +(match[i] || (i < 3 ? 1 : 0)); // parse the UTC offset component
// match[1] is the month. Months are 0-11 in JavaScript var year = Number(match[1]),
// `Date` objects, but 1-12 in ISO notation, so we month = Number(match[2] || 1) - 1,
// decrement. day = Number(match[3] || 1) - 1,
if (i == 1) { hour = Number(match[4] || 0),
match[i]--; minute = Number(match[5] || 0),
second = Number(match[6] || 0),
millisecond = Math.floor(Number(match[7] || 0) * 1000),
// When time zone is missed, local offset should be used
// (ES 5.1 bug)
// see https://bugs.ecmascript.org/show_bug.cgi?id=112
isLocalTime = Boolean(match[4] && !match[8]),
signOffset = match[9] === "-" ? 1 : -1,
hourOffset = Number(match[10] || 0),
minuteOffset = Number(match[11] || 0),
result;
if (
hour < (
minute > 0 || second > 0 || millisecond > 0 ?
24 : 25
) &&
minute < 60 && second < 60 && millisecond < 1000 &&
month > -1 && month < 12 && hourOffset < 24 &&
minuteOffset < 60 && // detect invalid offsets
day > -1 &&
day < (
dayFromMonth(year, month + 1) -
dayFromMonth(year, month)
)
) {
result = (
(dayFromMonth(year, month) + day) * 24 +
hour +
hourOffset * signOffset
) * 60;
result = (
(result + minute + minuteOffset * signOffset) * 60 +
second
) * 1000 + millisecond;
if (isLocalTime) {
result = toUTC(result);
}
if (-8.64e15 <= result && result <= 8.64e15) {
return result;
}
} }
return NaN;
} }
return NativeDate.parse.apply(this, arguments);
};
// parse the UTC offset component return Date;
var minuteOffset = +match.pop(), hourOffset = +match.pop(), sign = match.pop(); })(Date);
}
// compute the explicit time zone offset if specified // ES5 15.9.4.4
var offset = 0; // http://es5.github.com/#x15.9.4.4
if (sign) { if (!Date.now) {
// detect invalid offsets and return early Date.now = function now() {
if (hourOffset > 23 || minuteOffset > 59) { return new Date().getTime();
return NaN; };
}
//
// Number
// ======
//
// ES5.1 15.7.4.5
// http://es5.github.com/#x15.7.4.5
if (!Number.prototype.toFixed || (0.00008).toFixed(3) !== '0.000' || (0.9).toFixed(0) === '0' || (1.255).toFixed(2) !== '1.25' || (1000000000000000128).toFixed(0) !== "1000000000000000128") {
// Hide these variables and functions
(function () {
var base, size, data, i;
base = 1e7;
size = 6;
data = [0, 0, 0, 0, 0, 0];
function multiply(n, c) {
var i = -1;
while (++i < size) {
c += n * data[i];
data[i] = c % base;
c = Math.floor(c / base);
}
} }
// express the provided time zone offset in minutes. The offset is function divide(n) {
// negative for time zones west of UTC; positive otherwise. var i = size, c = 0;
offset = (hourOffset * 60 + minuteOffset) * 6e4 * (sign == "+" ? -1 : 1); while (--i >= 0) {
c += data[i];
data[i] = Math.floor(c / n);
c = (c % n) * base;
}
} }
// Date.UTC for years between 0 and 99 converts year to 1900 + year function toString() {
// The Gregorian calendar has a 400-year cycle, so var i = size;
// to Date.UTC(year + 400, .... ) - 12622780800000 == Date.UTC(year, ...), var s = '';
// where 12622780800000 - number of milliseconds in Gregorian calendar 400 years while (--i >= 0) {
var year = +match[0]; if (s !== '' || i === 0 || data[i] !== 0) {
if (0 <= year && year <= 99) { var t = String(data[i]);
match[0] = year + 400; if (s === '') {
return NativeDate.UTC.apply(this, match) + offset - 12622780800000; s = t;
} else {
s += '0000000'.slice(0, 7 - t.length) + t;
}
}
}
return s;
} }
// compute a new UTC date value, accounting for the optional offset function pow(x, n, acc) {
return NativeDate.UTC.apply(this, match) + offset; return (n === 0 ? acc : (n % 2 === 1 ? pow(x, n - 1, acc * x) : pow(x * x, n / 2, acc)));
} }
return NativeDate.parse.apply(this, arguments);
};
return Date; function log(x) {
})(Date); var n = 0;
while (x >= 4096) {
n += 12;
x /= 4096;
}
while (x >= 2) {
n += 1;
x /= 2;
}
return n;
}
Number.prototype.toFixed = function (fractionDigits) {
var f, x, s, m, e, z, j, k;
// Test for NaN and round fractionDigits down
f = Number(fractionDigits);
f = f !== f ? 0 : Math.floor(f);
if (f < 0 || f > 20) {
throw new RangeError("Number.toFixed called with invalid number of decimals");
}
x = Number(this);
// Test for NaN
if (x !== x) {
return "NaN";
}
// If it is too big or small, return the string value of the number
if (x <= -1e21 || x >= 1e21) {
return String(x);
}
s = "";
if (x < 0) {
s = "-";
x = -x;
}
m = "0";
if (x > 1e-21) {
// 1e-21 < x < 1e21
// -70 < log2(x) < 70
e = log(x * pow(2, 69, 1)) - 69;
z = (e < 0 ? x * pow(2, -e, 1) : x / pow(2, e, 1));
z *= 0x10000000000000; // Math.pow(2, 52);
e = 52 - e;
// -18 < e < 122
// x = z / 2 ^ e
if (e > 0) {
multiply(0, z);
j = f;
while (j >= 7) {
multiply(1e7, 0);
j -= 7;
}
multiply(pow(10, j, 1), 0);
j = e - 1;
while (j >= 23) {
divide(1 << 23);
j -= 23;
}
divide(1 << j);
multiply(1, 1);
divide(2);
m = toString();
} else {
multiply(0, z);
multiply(1 << (-e), 0);
m = toString() + '0.00000000000000000000'.slice(2, 2 + f);
}
}
if (f > 0) {
k = m.length;
if (k <= f) {
m = s + '0.0000000000000000000'.slice(0, f - k + 2) + m;
} else {
m = s + m.slice(0, k - f) + '.' + m.slice(k - f);
}
} else {
m = s + m;
}
return m;
}
}());
} }
// //
// String // String
// ====== // ======
// //
// ES5 15.5.4.14
// http://es5.github.com/#x15.5.4.14
// [bugfix, IE lt 9, firefox 4, Konqueror, Opera, obscure browsers]
// Many browsers do not split properly with regular expressions or they
// do not perform the split correctly under obscure conditions.
// See http://blog.stevenlevithan.com/archives/cross-browser-split
// I've tested in many browsers and this seems to cover the deviant ones:
// 'ab'.split(/(?:ab)*/) should be ["", ""], not [""]
// '.'.split(/(.?)(.?)/) should be ["", ".", "", ""], not ["", ""]
// 'tesst'.split(/(s)*/) should be ["t", undefined, "e", "s", "t"], not
// [undefined, "t", undefined, "e", ...]
// ''.split(/.?/) should be [], not [""]
// '.'.split(/()()/) should be ["."], not ["", "", "."]
var string_split = String.prototype.split;
if (
'ab'.split(/(?:ab)*/).length !== 2 ||
'.'.split(/(.?)(.?)/).length !== 4 ||
'tesst'.split(/(s)*/)[1] === "t" ||
''.split(/.?/).length ||
'.'.split(/()()/).length > 1
) {
(function () {
var compliantExecNpcg = /()??/.exec("")[1] === void 0; // NPCG: nonparticipating capturing group
String.prototype.split = function (separator, limit) {
var string = this;
if (separator === void 0 && limit === 0)
return [];
// If `separator` is not a regex, use native split
if (Object.prototype.toString.call(separator) !== "[object RegExp]") {
return string_split.apply(this, arguments);
}
var output = [],
flags = (separator.ignoreCase ? "i" : "") +
(separator.multiline ? "m" : "") +
(separator.extended ? "x" : "") + // Proposed for ES6
(separator.sticky ? "y" : ""), // Firefox 3+
lastLastIndex = 0,
// Make `global` and avoid `lastIndex` issues by working with a copy
separator = new RegExp(separator.source, flags + "g"),
separator2, match, lastIndex, lastLength;
string += ""; // Type-convert
if (!compliantExecNpcg) {
// Doesn't need flags gy, but they don't hurt
separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags);
}
/* Values for `limit`, per the spec:
* If undefined: 4294967295 // Math.pow(2, 32) - 1
* If 0, Infinity, or NaN: 0
* If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
* If negative number: 4294967296 - Math.floor(Math.abs(limit))
* If other: Type-convert, then use the above rules
*/
limit = limit === void 0 ?
-1 >>> 0 : // Math.pow(2, 32) - 1
limit >>> 0; // ToUint32(limit)
while (match = separator.exec(string)) {
// `separator.lastIndex` is not reliable cross-browser
lastIndex = match.index + match[0].length;
if (lastIndex > lastLastIndex) {
output.push(string.slice(lastLastIndex, match.index));
// Fix browsers whose `exec` methods don't consistently return `undefined` for
// nonparticipating capturing groups
if (!compliantExecNpcg && match.length > 1) {
match[0].replace(separator2, function () {
for (var i = 1; i < arguments.length - 2; i++) {
if (arguments[i] === void 0) {
match[i] = void 0;
}
}
});
}
if (match.length > 1 && match.index < string.length) {
Array.prototype.push.apply(output, match.slice(1));
}
lastLength = match[0].length;
lastLastIndex = lastIndex;
if (output.length >= limit) {
break;
}
}
if (separator.lastIndex === match.index) {
separator.lastIndex++; // Avoid an infinite loop
}
}
if (lastLastIndex === string.length) {
if (lastLength || !separator.test("")) {
output.push("");
}
} else {
output.push(string.slice(lastLastIndex));
}
return output.length > limit ? output.slice(0, limit) : output;
};
}());
// [bugfix, chrome]
// If separator is undefined, then the result array contains just one String,
// which is the this value (converted to a String). If limit is not undefined,
// then the output array is truncated so that it contains no more than limit
// elements.
// "0".split(undefined, 0) -> []
} else if ("0".split(void 0, 0).length) {
String.prototype.split = function(separator, limit) {
if (separator === void 0 && limit === 0) return [];
return string_split.apply(this, arguments);
}
}
// ECMA-262, 3rd B.2.3
// Note an ECMAScript standart, although ECMAScript 3rd Edition has a
// non-normative section suggesting uniform semantics and it should be
// normalized across all browsers
// [bugfix, IE lt 9] IE < 9 substr() with negative value not working in IE
if ("".substr && "0b".substr(-1) !== "b") {
var string_substr = String.prototype.substr;
/**
* Get the substring of a string
* @param {integer} start where to start the substring
* @param {integer} length how many characters to return
* @return {string}
*/
String.prototype.substr = function(start, length) {
return string_substr.call(
this,
start < 0 ? ((start = this.length + start) < 0 ? 0 : start) : start,
length
);
}
}
// ES5 15.5.4.20 // ES5 15.5.4.20
// http://es5.github.com/#x15.5.4.20 // http://es5.github.com/#x15.5.4.20
var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" + var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
...@@ -735,10 +1287,12 @@ if (!String.prototype.trim || ws.trim()) { ...@@ -735,10 +1287,12 @@ if (!String.prototype.trim || ws.trim()) {
var trimBeginRegexp = new RegExp("^" + ws + ws + "*"), var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
trimEndRegexp = new RegExp(ws + ws + "*$"); trimEndRegexp = new RegExp(ws + ws + "*$");
String.prototype.trim = function trim() { String.prototype.trim = function trim() {
if (this === undefined || this === null) { if (this === void 0 || this === null) {
throw new TypeError("can't convert "+this+" to object"); throw new TypeError("can't convert "+this+" to object");
} }
return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, ""); return String(this)
.replace(trimBeginRegexp, "")
.replace(trimEndRegexp, "");
}; };
} }
...@@ -750,7 +1304,8 @@ if (!String.prototype.trim || ws.trim()) { ...@@ -750,7 +1304,8 @@ if (!String.prototype.trim || ws.trim()) {
// ES5 9.4 // ES5 9.4
// http://es5.github.com/#x9.4 // http://es5.github.com/#x9.4
// http://jsperf.com/to-integer // http://jsperf.com/to-integer
var toInteger = function (n) {
function toInteger(n) {
n = +n; n = +n;
if (n !== n) { // isNaN if (n !== n) { // isNaN
n = 0; n = 0;
...@@ -758,20 +1313,47 @@ var toInteger = function (n) { ...@@ -758,20 +1313,47 @@ var toInteger = function (n) {
n = (n > 0 || -1) * Math.floor(Math.abs(n)); n = (n > 0 || -1) * Math.floor(Math.abs(n));
} }
return n; return n;
}; }
var prepareString = "a"[0] != "a"; function isPrimitive(input) {
// ES5 9.9 var type = typeof input;
// http://es5.github.com/#x9.9 return (
input === null ||
type === "undefined" ||
type === "boolean" ||
type === "number" ||
type === "string"
);
}
function toPrimitive(input) {
var val, valueOf, toString;
if (isPrimitive(input)) {
return input;
}
valueOf = input.valueOf;
if (typeof valueOf === "function") {
val = valueOf.call(input);
if (isPrimitive(val)) {
return val;
}
}
toString = input.toString;
if (typeof toString === "function") {
val = toString.call(input);
if (isPrimitive(val)) {
return val;
}
}
throw new TypeError();
}
// ES5 9.9
// http://es5.github.com/#x9.9
var toObject = function (o) { var toObject = function (o) {
if (o == null) { // this matches both null and undefined if (o == null) { // this matches both null and undefined
throw new TypeError("can't convert "+o+" to object"); throw new TypeError("can't convert "+o+" to object");
} }
// If the implementation doesn't support by-index access of
// string characters (ex. IE < 9), split the string
if (prepareString && typeof o == "string" && o) {
return o.split("");
}
return Object(o); return Object(o);
}; };
......
/*! /*!
* jQuery JavaScript Library v2.1.0 * jQuery JavaScript Library v2.1.3
* http://jquery.com/ * http://jquery.com/
* *
* Includes Sizzle.js * Includes Sizzle.js
...@@ -9,19 +9,19 @@ ...@@ -9,19 +9,19 @@
* Released under the MIT license * Released under the MIT license
* http://jquery.org/license * http://jquery.org/license
* *
* Date: 2014-01-23T21:10Z * Date: 2014-12-18T15:11Z
*/ */
(function( global, factory ) { (function( global, factory ) {
if ( typeof module === "object" && typeof module.exports === "object" ) { if ( typeof module === "object" && typeof module.exports === "object" ) {
// For CommonJS and CommonJS-like environments where a proper window is present, // For CommonJS and CommonJS-like environments where a proper `window`
// execute the factory and get jQuery // is present, execute the factory and get jQuery.
// For environments that do not inherently posses a window with a document // For environments that do not have a `window` with a `document`
// (such as Node.js), expose a jQuery-making factory as module.exports // (such as Node.js), expose a factory as module.exports.
// This accentuates the need for the creation of a real window // This accentuates the need for the creation of a real `window`.
// e.g. var jQuery = require("jquery")(window); // e.g. var jQuery = require("jquery")(window);
// See ticket #14549 for more info // See ticket #14549 for more info.
module.exports = global.document ? module.exports = global.document ?
factory( global, true ) : factory( global, true ) :
function( w ) { function( w ) {
...@@ -37,10 +37,10 @@ ...@@ -37,10 +37,10 @@
// Pass this if window is not defined yet // Pass this if window is not defined yet
}(typeof window !== "undefined" ? window : this, function( window, noGlobal ) { }(typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
// Can't do this because several apps including ASP.NET trace // Support: Firefox 18+
// Can't be in strict mode, several libs including ASP.NET trace
// the stack via arguments.caller.callee and Firefox dies if // the stack via arguments.caller.callee and Firefox dies if
// you try to trace through "use strict" call chains. (#13335) // you try to trace through "use strict" call chains. (#13335)
// Support: Firefox 18+
// //
var arr = []; var arr = [];
...@@ -59,8 +59,6 @@ var toString = class2type.toString; ...@@ -59,8 +59,6 @@ var toString = class2type.toString;
var hasOwn = class2type.hasOwnProperty; var hasOwn = class2type.hasOwnProperty;
var trim = "".trim;
var support = {}; var support = {};
...@@ -69,7 +67,7 @@ var ...@@ -69,7 +67,7 @@ var
// Use the correct document accordingly with window argument (sandbox) // Use the correct document accordingly with window argument (sandbox)
document = window.document, document = window.document,
version = "2.1.0", version = "2.1.3",
// Define a local copy of jQuery // Define a local copy of jQuery
jQuery = function( selector, context ) { jQuery = function( selector, context ) {
...@@ -78,6 +76,10 @@ var ...@@ -78,6 +76,10 @@ var
return new jQuery.fn.init( selector, context ); return new jQuery.fn.init( selector, context );
}, },
// Support: Android<4.1
// Make sure we trim BOM and NBSP
rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,
// Matches dashed string for camelizing // Matches dashed string for camelizing
rmsPrefix = /^-ms-/, rmsPrefix = /^-ms-/,
rdashAlpha = /-([\da-z])/gi, rdashAlpha = /-([\da-z])/gi,
...@@ -108,10 +110,10 @@ jQuery.fn = jQuery.prototype = { ...@@ -108,10 +110,10 @@ jQuery.fn = jQuery.prototype = {
get: function( num ) { get: function( num ) {
return num != null ? return num != null ?
// Return a 'clean' array // Return just the one element from the set
( num < 0 ? this[ num + this.length ] : this[ num ] ) : ( num < 0 ? this[ num + this.length ] : this[ num ] ) :
// Return just the object // Return all the elements in a clean array
slice.call( this ); slice.call( this );
}, },
...@@ -183,7 +185,7 @@ jQuery.extend = jQuery.fn.extend = function() { ...@@ -183,7 +185,7 @@ jQuery.extend = jQuery.fn.extend = function() {
if ( typeof target === "boolean" ) { if ( typeof target === "boolean" ) {
deep = target; deep = target;
// skip the boolean and the target // Skip the boolean and the target
target = arguments[ i ] || {}; target = arguments[ i ] || {};
i++; i++;
} }
...@@ -193,7 +195,7 @@ jQuery.extend = jQuery.fn.extend = function() { ...@@ -193,7 +195,7 @@ jQuery.extend = jQuery.fn.extend = function() {
target = {}; target = {};
} }
// extend jQuery itself if only one argument is passed // Extend jQuery itself if only one argument is passed
if ( i === length ) { if ( i === length ) {
target = this; target = this;
i--; i--;
...@@ -250,9 +252,6 @@ jQuery.extend({ ...@@ -250,9 +252,6 @@ jQuery.extend({
noop: function() {}, noop: function() {},
// See test/unit/core.js for details concerning isFunction.
// Since version 1.3, DOM methods and functions like alert
// aren't supported. They return false on IE (#2968).
isFunction: function( obj ) { isFunction: function( obj ) {
return jQuery.type(obj) === "function"; return jQuery.type(obj) === "function";
}, },
...@@ -267,7 +266,8 @@ jQuery.extend({ ...@@ -267,7 +266,8 @@ jQuery.extend({
// parseFloat NaNs numeric-cast false positives (null|true|false|"") // parseFloat NaNs numeric-cast false positives (null|true|false|"")
// ...but misinterprets leading-number strings, particularly hex literals ("0x...") // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
// subtraction forces infinities to NaN // subtraction forces infinities to NaN
return obj - parseFloat( obj ) >= 0; // adding 1 corrects loss of precision from parseFloat (#15100)
return !jQuery.isArray( obj ) && (obj - parseFloat( obj ) + 1) >= 0;
}, },
isPlainObject: function( obj ) { isPlainObject: function( obj ) {
...@@ -279,18 +279,10 @@ jQuery.extend({ ...@@ -279,18 +279,10 @@ jQuery.extend({
return false; return false;
} }
// Support: Firefox <20
// The try/catch suppresses exceptions thrown when attempting to access
// the "constructor" property of certain host objects, ie. |window.location|
// https://bugzilla.mozilla.org/show_bug.cgi?id=814622
try {
if ( obj.constructor && if ( obj.constructor &&
!hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) { !hasOwn.call( obj.constructor.prototype, "isPrototypeOf" ) ) {
return false; return false;
} }
} catch ( e ) {
return false;
}
// If the function hasn't returned already, we're confident that // If the function hasn't returned already, we're confident that
// |obj| is a plain object, created by {} or constructed with new Object // |obj| is a plain object, created by {} or constructed with new Object
...@@ -309,7 +301,7 @@ jQuery.extend({ ...@@ -309,7 +301,7 @@ jQuery.extend({
if ( obj == null ) { if ( obj == null ) {
return obj + ""; return obj + "";
} }
// Support: Android < 4.0, iOS < 6 (functionish RegExp) // Support: Android<4.0, iOS<6 (functionish RegExp)
return typeof obj === "object" || typeof obj === "function" ? return typeof obj === "object" || typeof obj === "function" ?
class2type[ toString.call(obj) ] || "object" : class2type[ toString.call(obj) ] || "object" :
typeof obj; typeof obj;
...@@ -339,6 +331,7 @@ jQuery.extend({ ...@@ -339,6 +331,7 @@ jQuery.extend({
}, },
// Convert dashed to camelCase; used by the css and data modules // Convert dashed to camelCase; used by the css and data modules
// Support: IE9-11+
// Microsoft forgot to hump their vendor prefix (#9572) // Microsoft forgot to hump their vendor prefix (#9572)
camelCase: function( string ) { camelCase: function( string ) {
return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
...@@ -398,8 +391,11 @@ jQuery.extend({ ...@@ -398,8 +391,11 @@ jQuery.extend({
return obj; return obj;
}, },
// Support: Android<4.1
trim: function( text ) { trim: function( text ) {
return text == null ? "" : trim.call( text ); return text == null ?
"" :
( text + "" ).replace( rtrim, "" );
}, },
// results is for internal usage only // results is for internal usage only
...@@ -551,14 +547,14 @@ function isArraylike( obj ) { ...@@ -551,14 +547,14 @@ function isArraylike( obj ) {
} }
var Sizzle = var Sizzle =
/*! /*!
* Sizzle CSS Selector Engine v1.10.16 * Sizzle CSS Selector Engine v2.2.0-pre
* http://sizzlejs.com/ * http://sizzlejs.com/
* *
* Copyright 2013 jQuery Foundation, Inc. and other contributors * Copyright 2008, 2014 jQuery Foundation, Inc. and other contributors
* Released under the MIT license * Released under the MIT license
* http://jquery.org/license * http://jquery.org/license
* *
* Date: 2014-01-13 * Date: 2014-12-16
*/ */
(function( window ) { (function( window ) {
...@@ -567,7 +563,9 @@ var i, ...@@ -567,7 +563,9 @@ var i,
Expr, Expr,
getText, getText,
isXML, isXML,
tokenize,
compile, compile,
select,
outermostContext, outermostContext,
sortInput, sortInput,
hasDuplicate, hasDuplicate,
...@@ -583,7 +581,7 @@ var i, ...@@ -583,7 +581,7 @@ var i,
contains, contains,
// Instance-specific data // Instance-specific data
expando = "sizzle" + -(new Date()), expando = "sizzle" + 1 * new Date(),
preferredDoc = window.document, preferredDoc = window.document,
dirruns = 0, dirruns = 0,
done = 0, done = 0,
...@@ -598,7 +596,6 @@ var i, ...@@ -598,7 +596,6 @@ var i,
}, },
// General-purpose constants // General-purpose constants
strundefined = typeof undefined,
MAX_NEGATIVE = 1 << 31, MAX_NEGATIVE = 1 << 31,
// Instance methods // Instance methods
...@@ -608,12 +605,13 @@ var i, ...@@ -608,12 +605,13 @@ var i,
push_native = arr.push, push_native = arr.push,
push = arr.push, push = arr.push,
slice = arr.slice, slice = arr.slice,
// Use a stripped-down indexOf if we can't use a native one // Use a stripped-down indexOf as it's faster than native
indexOf = arr.indexOf || function( elem ) { // http://jsperf.com/thor-indexof-vs-for/5
indexOf = function( list, elem ) {
var i = 0, var i = 0,
len = this.length; len = list.length;
for ( ; i < len; i++ ) { for ( ; i < len; i++ ) {
if ( this[i] === elem ) { if ( list[i] === elem ) {
return i; return i;
} }
} }
...@@ -634,19 +632,26 @@ var i, ...@@ -634,19 +632,26 @@ var i,
// Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier // Proper syntax: http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
identifier = characterEncoding.replace( "w", "w#" ), identifier = characterEncoding.replace( "w", "w#" ),
// Acceptable operators http://www.w3.org/TR/selectors/#attribute-selectors // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
attributes = "\\[" + whitespace + "*(" + characterEncoding + ")" + whitespace + attributes = "\\[" + whitespace + "*(" + characterEncoding + ")(?:" + whitespace +
"*(?:([*^$|!~]?=)" + whitespace + "*(?:(['\"])((?:\\\\.|[^\\\\])*?)\\3|(" + identifier + ")|)|)" + whitespace + "*\\]", // Operator (capture 2)
"*([*^$|!~]?=)" + whitespace +
// Prefer arguments quoted, // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
// then not containing pseudos/brackets, "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
// then attribute selectors/non-parenthetical expressions, "*\\]",
// then anything else
// These preferences are here to reduce the number of selectors pseudos = ":(" + characterEncoding + ")(?:\\((" +
// needing tokenize in the PSEUDO preFilter // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
pseudos = ":(" + characterEncoding + ")(?:\\(((['\"])((?:\\\\.|[^\\\\])*?)\\3|((?:\\\\.|[^\\\\()[\\]]|" + attributes.replace( 3, 8 ) + ")*)|.*)\\)|)", // 1. quoted (capture 3; capture 4 or capture 5)
"('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
// 2. simple (capture 6)
"((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
// 3. anything else (capture 2)
".*" +
")\\)|)",
// Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
rwhitespace = new RegExp( whitespace + "+", "g" ),
rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ), rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ), rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
...@@ -689,7 +694,7 @@ var i, ...@@ -689,7 +694,7 @@ var i,
funescape = function( _, escaped, escapedWhitespace ) { funescape = function( _, escaped, escapedWhitespace ) {
var high = "0x" + escaped - 0x10000; var high = "0x" + escaped - 0x10000;
// NaN means non-codepoint // NaN means non-codepoint
// Support: Firefox // Support: Firefox<24
// Workaround erroneous numeric interpretation of +"0x" // Workaround erroneous numeric interpretation of +"0x"
return high !== high || escapedWhitespace ? return high !== high || escapedWhitespace ?
escaped : escaped :
...@@ -698,6 +703,14 @@ var i, ...@@ -698,6 +703,14 @@ var i,
String.fromCharCode( high + 0x10000 ) : String.fromCharCode( high + 0x10000 ) :
// Supplemental Plane codepoint (surrogate pair) // Supplemental Plane codepoint (surrogate pair)
String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 ); String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
},
// Used for iframes
// See setDocument()
// Removing the function wrapper causes a "Permission Denied"
// error in IE
unloadHandler = function() {
setDocument();
}; };
// Optimize for push.apply( _, NodeList ) // Optimize for push.apply( _, NodeList )
...@@ -740,19 +753,18 @@ function Sizzle( selector, context, results, seed ) { ...@@ -740,19 +753,18 @@ function Sizzle( selector, context, results, seed ) {
context = context || document; context = context || document;
results = results || []; results = results || [];
nodeType = context.nodeType;
if ( !selector || typeof selector !== "string" ) { if ( typeof selector !== "string" || !selector ||
return results; nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
}
if ( (nodeType = context.nodeType) !== 1 && nodeType !== 9 ) { return results;
return [];
} }
if ( documentIsHTML && !seed ) { if ( !seed && documentIsHTML ) {
// Shortcuts // Try to shortcut find operations when possible (e.g., not under DocumentFragment)
if ( (match = rquickExpr.exec( selector )) ) { if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
// Speed-up: Sizzle("#ID") // Speed-up: Sizzle("#ID")
if ( (m = match[1]) ) { if ( (m = match[1]) ) {
if ( nodeType === 9 ) { if ( nodeType === 9 ) {
...@@ -784,7 +796,7 @@ function Sizzle( selector, context, results, seed ) { ...@@ -784,7 +796,7 @@ function Sizzle( selector, context, results, seed ) {
return results; return results;
// Speed-up: Sizzle(".CLASS") // Speed-up: Sizzle(".CLASS")
} else if ( (m = match[3]) && support.getElementsByClassName && context.getElementsByClassName ) { } else if ( (m = match[3]) && support.getElementsByClassName ) {
push.apply( results, context.getElementsByClassName( m ) ); push.apply( results, context.getElementsByClassName( m ) );
return results; return results;
} }
...@@ -794,7 +806,7 @@ function Sizzle( selector, context, results, seed ) { ...@@ -794,7 +806,7 @@ function Sizzle( selector, context, results, seed ) {
if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) { if ( support.qsa && (!rbuggyQSA || !rbuggyQSA.test( selector )) ) {
nid = old = expando; nid = old = expando;
newContext = context; newContext = context;
newSelector = nodeType === 9 && selector; newSelector = nodeType !== 1 && selector;
// qSA works strangely on Element-rooted queries // qSA works strangely on Element-rooted queries
// We can work around this by specifying an extra ID on the root // We can work around this by specifying an extra ID on the root
...@@ -981,7 +993,7 @@ function createPositionalPseudo( fn ) { ...@@ -981,7 +993,7 @@ function createPositionalPseudo( fn ) {
* @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
*/ */
function testContext( context ) { function testContext( context ) {
return context && typeof context.getElementsByTagName !== strundefined && context; return context && typeof context.getElementsByTagName !== "undefined" && context;
} }
// Expose support vars for convenience // Expose support vars for convenience
...@@ -1005,9 +1017,8 @@ isXML = Sizzle.isXML = function( elem ) { ...@@ -1005,9 +1017,8 @@ isXML = Sizzle.isXML = function( elem ) {
* @returns {Object} Returns the current document * @returns {Object} Returns the current document
*/ */
setDocument = Sizzle.setDocument = function( node ) { setDocument = Sizzle.setDocument = function( node ) {
var hasCompare, var hasCompare, parent,
doc = node ? node.ownerDocument || node : preferredDoc, doc = node ? node.ownerDocument || node : preferredDoc;
parent = doc.defaultView;
// If no document and documentElement is available, return // If no document and documentElement is available, return
if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) { if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
...@@ -1017,9 +1028,7 @@ setDocument = Sizzle.setDocument = function( node ) { ...@@ -1017,9 +1028,7 @@ setDocument = Sizzle.setDocument = function( node ) {
// Set our document // Set our document
document = doc; document = doc;
docElem = doc.documentElement; docElem = doc.documentElement;
parent = doc.defaultView;
// Support tests
documentIsHTML = !isXML( doc );
// Support: IE>8 // Support: IE>8
// If iframe document is assigned to "document" variable and if iframe has been reloaded, // If iframe document is assigned to "document" variable and if iframe has been reloaded,
...@@ -1028,21 +1037,22 @@ setDocument = Sizzle.setDocument = function( node ) { ...@@ -1028,21 +1037,22 @@ setDocument = Sizzle.setDocument = function( node ) {
if ( parent && parent !== parent.top ) { if ( parent && parent !== parent.top ) {
// IE11 does not have attachEvent, so all must suffer // IE11 does not have attachEvent, so all must suffer
if ( parent.addEventListener ) { if ( parent.addEventListener ) {
parent.addEventListener( "unload", function() { parent.addEventListener( "unload", unloadHandler, false );
setDocument();
}, false );
} else if ( parent.attachEvent ) { } else if ( parent.attachEvent ) {
parent.attachEvent( "onunload", function() { parent.attachEvent( "onunload", unloadHandler );
setDocument();
});
} }
} }
/* Support tests
---------------------------------------------------------------------- */
documentIsHTML = !isXML( doc );
/* Attributes /* Attributes
---------------------------------------------------------------------- */ ---------------------------------------------------------------------- */
// Support: IE<8 // Support: IE<8
// Verify that getAttribute really returns attributes and not properties (excepting IE8 booleans) // Verify that getAttribute really returns attributes and not properties
// (excepting IE8 booleans)
support.attributes = assert(function( div ) { support.attributes = assert(function( div ) {
div.className = "i"; div.className = "i";
return !div.getAttribute("className"); return !div.getAttribute("className");
...@@ -1057,17 +1067,8 @@ setDocument = Sizzle.setDocument = function( node ) { ...@@ -1057,17 +1067,8 @@ setDocument = Sizzle.setDocument = function( node ) {
return !div.getElementsByTagName("*").length; return !div.getElementsByTagName("*").length;
}); });
// Check if getElementsByClassName can be trusted // Support: IE<9
support.getElementsByClassName = rnative.test( doc.getElementsByClassName ) && assert(function( div ) { support.getElementsByClassName = rnative.test( doc.getElementsByClassName );
div.innerHTML = "<div class='a'></div><div class='a i'></div>";
// Support: Safari<4
// Catch class over-caching
div.firstChild.className = "i";
// Support: Opera<10
// Catch gEBCN failure to find non-leading classes
return div.getElementsByClassName("i").length === 2;
});
// Support: IE<10 // Support: IE<10
// Check if getElementById returns elements by name // Check if getElementById returns elements by name
...@@ -1081,11 +1082,11 @@ setDocument = Sizzle.setDocument = function( node ) { ...@@ -1081,11 +1082,11 @@ setDocument = Sizzle.setDocument = function( node ) {
// ID find and filter // ID find and filter
if ( support.getById ) { if ( support.getById ) {
Expr.find["ID"] = function( id, context ) { Expr.find["ID"] = function( id, context ) {
if ( typeof context.getElementById !== strundefined && documentIsHTML ) { if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
var m = context.getElementById( id ); var m = context.getElementById( id );
// Check parentNode to catch when Blackberry 4.6 returns // Check parentNode to catch when Blackberry 4.6 returns
// nodes that are no longer in the document #6963 // nodes that are no longer in the document #6963
return m && m.parentNode ? [m] : []; return m && m.parentNode ? [ m ] : [];
} }
}; };
Expr.filter["ID"] = function( id ) { Expr.filter["ID"] = function( id ) {
...@@ -1102,7 +1103,7 @@ setDocument = Sizzle.setDocument = function( node ) { ...@@ -1102,7 +1103,7 @@ setDocument = Sizzle.setDocument = function( node ) {
Expr.filter["ID"] = function( id ) { Expr.filter["ID"] = function( id ) {
var attrId = id.replace( runescape, funescape ); var attrId = id.replace( runescape, funescape );
return function( elem ) { return function( elem ) {
var node = typeof elem.getAttributeNode !== strundefined && elem.getAttributeNode("id"); var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
return node && node.value === attrId; return node && node.value === attrId;
}; };
}; };
...@@ -1111,14 +1112,20 @@ setDocument = Sizzle.setDocument = function( node ) { ...@@ -1111,14 +1112,20 @@ setDocument = Sizzle.setDocument = function( node ) {
// Tag // Tag
Expr.find["TAG"] = support.getElementsByTagName ? Expr.find["TAG"] = support.getElementsByTagName ?
function( tag, context ) { function( tag, context ) {
if ( typeof context.getElementsByTagName !== strundefined ) { if ( typeof context.getElementsByTagName !== "undefined" ) {
return context.getElementsByTagName( tag ); return context.getElementsByTagName( tag );
// DocumentFragment nodes don't have gEBTN
} else if ( support.qsa ) {
return context.querySelectorAll( tag );
} }
} : } :
function( tag, context ) { function( tag, context ) {
var elem, var elem,
tmp = [], tmp = [],
i = 0, i = 0,
// By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
results = context.getElementsByTagName( tag ); results = context.getElementsByTagName( tag );
// Filter out possible comments // Filter out possible comments
...@@ -1136,7 +1143,7 @@ setDocument = Sizzle.setDocument = function( node ) { ...@@ -1136,7 +1143,7 @@ setDocument = Sizzle.setDocument = function( node ) {
// Class // Class
Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) { Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
if ( typeof context.getElementsByClassName !== strundefined && documentIsHTML ) { if ( documentIsHTML ) {
return context.getElementsByClassName( className ); return context.getElementsByClassName( className );
} }
}; };
...@@ -1165,11 +1172,15 @@ setDocument = Sizzle.setDocument = function( node ) { ...@@ -1165,11 +1172,15 @@ setDocument = Sizzle.setDocument = function( node ) {
// setting a boolean content attribute, // setting a boolean content attribute,
// since its presence should be enough // since its presence should be enough
// http://bugs.jquery.com/ticket/12359 // http://bugs.jquery.com/ticket/12359
div.innerHTML = "<select t=''><option selected=''></option></select>"; docElem.appendChild( div ).innerHTML = "<a id='" + expando + "'></a>" +
"<select id='" + expando + "-\f]' msallowcapture=''>" +
"<option selected=''></option></select>";
// Support: IE8, Opera 10-12 // Support: IE8, Opera 11-12.16
// Nothing should be selected when empty strings follow ^= or $= or *= // Nothing should be selected when empty strings follow ^= or $= or *=
if ( div.querySelectorAll("[t^='']").length ) { // The test attribute must be unknown in Opera but "safe" for WinRT
// http://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
if ( div.querySelectorAll("[msallowcapture^='']").length ) {
rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" ); rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
} }
...@@ -1179,12 +1190,24 @@ setDocument = Sizzle.setDocument = function( node ) { ...@@ -1179,12 +1190,24 @@ setDocument = Sizzle.setDocument = function( node ) {
rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" ); rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
} }
// Support: Chrome<29, Android<4.2+, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.7+
if ( !div.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
rbuggyQSA.push("~=");
}
// Webkit/Opera - :checked should return selected option elements // Webkit/Opera - :checked should return selected option elements
// http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
// IE8 throws error here and will not see later tests // IE8 throws error here and will not see later tests
if ( !div.querySelectorAll(":checked").length ) { if ( !div.querySelectorAll(":checked").length ) {
rbuggyQSA.push(":checked"); rbuggyQSA.push(":checked");
} }
// Support: Safari 8+, iOS 8+
// https://bugs.webkit.org/show_bug.cgi?id=136851
// In-page `selector#id sibing-combinator selector` fails
if ( !div.querySelectorAll( "a#" + expando + "+*" ).length ) {
rbuggyQSA.push(".#.+[+~]");
}
}); });
assert(function( div ) { assert(function( div ) {
...@@ -1212,7 +1235,8 @@ setDocument = Sizzle.setDocument = function( node ) { ...@@ -1212,7 +1235,8 @@ setDocument = Sizzle.setDocument = function( node ) {
}); });
} }
if ( (support.matchesSelector = rnative.test( (matches = docElem.webkitMatchesSelector || if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
docElem.webkitMatchesSelector ||
docElem.mozMatchesSelector || docElem.mozMatchesSelector ||
docElem.oMatchesSelector || docElem.oMatchesSelector ||
docElem.msMatchesSelector) )) ) { docElem.msMatchesSelector) )) ) {
...@@ -1300,7 +1324,7 @@ setDocument = Sizzle.setDocument = function( node ) { ...@@ -1300,7 +1324,7 @@ setDocument = Sizzle.setDocument = function( node ) {
// Maintain original order // Maintain original order
return sortInput ? return sortInput ?
( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) : ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
0; 0;
} }
...@@ -1327,7 +1351,7 @@ setDocument = Sizzle.setDocument = function( node ) { ...@@ -1327,7 +1351,7 @@ setDocument = Sizzle.setDocument = function( node ) {
aup ? -1 : aup ? -1 :
bup ? 1 : bup ? 1 :
sortInput ? sortInput ?
( indexOf.call( sortInput, a ) - indexOf.call( sortInput, b ) ) : ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
0; 0;
// If the nodes are siblings, we can do a quick check // If the nodes are siblings, we can do a quick check
...@@ -1390,10 +1414,10 @@ Sizzle.matchesSelector = function( elem, expr ) { ...@@ -1390,10 +1414,10 @@ Sizzle.matchesSelector = function( elem, expr ) {
elem.document && elem.document.nodeType !== 11 ) { elem.document && elem.document.nodeType !== 11 ) {
return ret; return ret;
} }
} catch(e) {} } catch (e) {}
} }
return Sizzle( expr, document, null, [elem] ).length > 0; return Sizzle( expr, document, null, [ elem ] ).length > 0;
}; };
Sizzle.contains = function( context, elem ) { Sizzle.contains = function( context, elem ) {
...@@ -1522,7 +1546,7 @@ Expr = Sizzle.selectors = { ...@@ -1522,7 +1546,7 @@ Expr = Sizzle.selectors = {
match[1] = match[1].replace( runescape, funescape ); match[1] = match[1].replace( runescape, funescape );
// Move the given value to match[3] whether quoted or unquoted // Move the given value to match[3] whether quoted or unquoted
match[3] = ( match[4] || match[5] || "" ).replace( runescape, funescape ); match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
if ( match[2] === "~=" ) { if ( match[2] === "~=" ) {
match[3] = " " + match[3] + " "; match[3] = " " + match[3] + " ";
...@@ -1565,15 +1589,15 @@ Expr = Sizzle.selectors = { ...@@ -1565,15 +1589,15 @@ Expr = Sizzle.selectors = {
"PSEUDO": function( match ) { "PSEUDO": function( match ) {
var excess, var excess,
unquoted = !match[5] && match[2]; unquoted = !match[6] && match[2];
if ( matchExpr["CHILD"].test( match[0] ) ) { if ( matchExpr["CHILD"].test( match[0] ) ) {
return null; return null;
} }
// Accept quoted arguments as-is // Accept quoted arguments as-is
if ( match[3] && match[4] !== undefined ) { if ( match[3] ) {
match[2] = match[4]; match[2] = match[4] || match[5] || "";
// Strip excess characters from unquoted arguments // Strip excess characters from unquoted arguments
} else if ( unquoted && rpseudo.test( unquoted ) && } else if ( unquoted && rpseudo.test( unquoted ) &&
...@@ -1609,7 +1633,7 @@ Expr = Sizzle.selectors = { ...@@ -1609,7 +1633,7 @@ Expr = Sizzle.selectors = {
return pattern || return pattern ||
(pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) && (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
classCache( className, function( elem ) { classCache( className, function( elem ) {
return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== strundefined && elem.getAttribute("class") || "" ); return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
}); });
}, },
...@@ -1631,7 +1655,7 @@ Expr = Sizzle.selectors = { ...@@ -1631,7 +1655,7 @@ Expr = Sizzle.selectors = {
operator === "^=" ? check && result.indexOf( check ) === 0 : operator === "^=" ? check && result.indexOf( check ) === 0 :
operator === "*=" ? check && result.indexOf( check ) > -1 : operator === "*=" ? check && result.indexOf( check ) > -1 :
operator === "$=" ? check && result.slice( -check.length ) === check : operator === "$=" ? check && result.slice( -check.length ) === check :
operator === "~=" ? ( " " + result + " " ).indexOf( check ) > -1 : operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" : operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
false; false;
}; };
...@@ -1751,7 +1775,7 @@ Expr = Sizzle.selectors = { ...@@ -1751,7 +1775,7 @@ Expr = Sizzle.selectors = {
matched = fn( seed, argument ), matched = fn( seed, argument ),
i = matched.length; i = matched.length;
while ( i-- ) { while ( i-- ) {
idx = indexOf.call( seed, matched[i] ); idx = indexOf( seed, matched[i] );
seed[ idx ] = !( matches[ idx ] = matched[i] ); seed[ idx ] = !( matches[ idx ] = matched[i] );
} }
}) : }) :
...@@ -1790,6 +1814,8 @@ Expr = Sizzle.selectors = { ...@@ -1790,6 +1814,8 @@ Expr = Sizzle.selectors = {
function( elem, context, xml ) { function( elem, context, xml ) {
input[0] = elem; input[0] = elem;
matcher( input, null, xml, results ); matcher( input, null, xml, results );
// Don't keep the element (issue #299)
input[0] = null;
return !results.pop(); return !results.pop();
}; };
}), }),
...@@ -1801,6 +1827,7 @@ Expr = Sizzle.selectors = { ...@@ -1801,6 +1827,7 @@ Expr = Sizzle.selectors = {
}), }),
"contains": markFunction(function( text ) { "contains": markFunction(function( text ) {
text = text.replace( runescape, funescape );
return function( elem ) { return function( elem ) {
return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1; return ( elem.textContent || elem.innerText || getText( elem ) ).indexOf( text ) > -1;
}; };
...@@ -1978,7 +2005,7 @@ function setFilters() {} ...@@ -1978,7 +2005,7 @@ function setFilters() {}
setFilters.prototype = Expr.filters = Expr.pseudos; setFilters.prototype = Expr.filters = Expr.pseudos;
Expr.setFilters = new setFilters(); Expr.setFilters = new setFilters();
function tokenize( selector, parseOnly ) { tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
var matched, match, tokens, type, var matched, match, tokens, type,
soFar, groups, preFilters, soFar, groups, preFilters,
cached = tokenCache[ selector + " " ]; cached = tokenCache[ selector + " " ];
...@@ -2043,7 +2070,7 @@ function tokenize( selector, parseOnly ) { ...@@ -2043,7 +2070,7 @@ function tokenize( selector, parseOnly ) {
Sizzle.error( selector ) : Sizzle.error( selector ) :
// Cache the tokens // Cache the tokens
tokenCache( selector, groups ).slice( 0 ); tokenCache( selector, groups ).slice( 0 );
} };
function toSelector( tokens ) { function toSelector( tokens ) {
var i = 0, var i = 0,
...@@ -2122,6 +2149,15 @@ function elementMatcher( matchers ) { ...@@ -2122,6 +2149,15 @@ function elementMatcher( matchers ) {
matchers[0]; matchers[0];
} }
function multipleContexts( selector, contexts, results ) {
var i = 0,
len = contexts.length;
for ( ; i < len; i++ ) {
Sizzle( selector, contexts[i], results );
}
return results;
}
function condense( unmatched, map, filter, context, xml ) { function condense( unmatched, map, filter, context, xml ) {
var elem, var elem,
newUnmatched = [], newUnmatched = [],
...@@ -2213,7 +2249,7 @@ function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postS ...@@ -2213,7 +2249,7 @@ function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postS
i = matcherOut.length; i = matcherOut.length;
while ( i-- ) { while ( i-- ) {
if ( (elem = matcherOut[i]) && if ( (elem = matcherOut[i]) &&
(temp = postFinder ? indexOf.call( seed, elem ) : preMap[i]) > -1 ) { (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
seed[temp] = !(results[temp] = elem); seed[temp] = !(results[temp] = elem);
} }
...@@ -2248,13 +2284,16 @@ function matcherFromTokens( tokens ) { ...@@ -2248,13 +2284,16 @@ function matcherFromTokens( tokens ) {
return elem === checkContext; return elem === checkContext;
}, implicitRelative, true ), }, implicitRelative, true ),
matchAnyContext = addCombinator( function( elem ) { matchAnyContext = addCombinator( function( elem ) {
return indexOf.call( checkContext, elem ) > -1; return indexOf( checkContext, elem ) > -1;
}, implicitRelative, true ), }, implicitRelative, true ),
matchers = [ function( elem, context, xml ) { matchers = [ function( elem, context, xml ) {
return ( !leadingRelative && ( xml || context !== outermostContext ) ) || ( var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
(checkContext = context).nodeType ? (checkContext = context).nodeType ?
matchContext( elem, context, xml ) : matchContext( elem, context, xml ) :
matchAnyContext( elem, context, xml ) ); matchAnyContext( elem, context, xml ) );
// Avoid hanging onto element (issue #299)
checkContext = null;
return ret;
} ]; } ];
for ( ; i < len; i++ ) { for ( ; i < len; i++ ) {
...@@ -2390,7 +2429,7 @@ function matcherFromGroupMatchers( elementMatchers, setMatchers ) { ...@@ -2390,7 +2429,7 @@ function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
superMatcher; superMatcher;
} }
compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) { compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
var i, var i,
setMatchers = [], setMatchers = [],
elementMatchers = [], elementMatchers = [],
...@@ -2398,12 +2437,12 @@ compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) { ...@@ -2398,12 +2437,12 @@ compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
if ( !cached ) { if ( !cached ) {
// Generate a function of recursive functions that can be used to check each element // Generate a function of recursive functions that can be used to check each element
if ( !group ) { if ( !match ) {
group = tokenize( selector ); match = tokenize( selector );
} }
i = group.length; i = match.length;
while ( i-- ) { while ( i-- ) {
cached = matcherFromTokens( group[i] ); cached = matcherFromTokens( match[i] );
if ( cached[ expando ] ) { if ( cached[ expando ] ) {
setMatchers.push( cached ); setMatchers.push( cached );
} else { } else {
...@@ -2413,25 +2452,30 @@ compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) { ...@@ -2413,25 +2452,30 @@ compile = Sizzle.compile = function( selector, group /* Internal Use Only */ ) {
// Cache the compiled function // Cache the compiled function
cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) ); cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
// Save selector and tokenization
cached.selector = selector;
} }
return cached; return cached;
}; };
function multipleContexts( selector, contexts, results ) { /**
var i = 0, * A low-level selection function that works with Sizzle's compiled
len = contexts.length; * selector functions
for ( ; i < len; i++ ) { * @param {String|Function} selector A selector or a pre-compiled
Sizzle( selector, contexts[i], results ); * selector function built with Sizzle.compile
} * @param {Element} context
return results; * @param {Array} [results]
} * @param {Array} [seed] A set of elements to match against
*/
function select( selector, context, results, seed ) { select = Sizzle.select = function( selector, context, results, seed ) {
var i, tokens, token, type, find, var i, tokens, token, type, find,
match = tokenize( selector ); compiled = typeof selector === "function" && selector,
match = !seed && tokenize( (selector = compiled.selector || selector) );
results = results || [];
if ( !seed ) { // Try to minimize operations if there is no seed and only one group
// Try to minimize operations if there is only one group
if ( match.length === 1 ) { if ( match.length === 1 ) {
// Take a shortcut and set the context if the root selector is an ID // Take a shortcut and set the context if the root selector is an ID
...@@ -2443,7 +2487,12 @@ function select( selector, context, results, seed ) { ...@@ -2443,7 +2487,12 @@ function select( selector, context, results, seed ) {
context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0]; context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
if ( !context ) { if ( !context ) {
return results; return results;
// Precompiled matchers will still verify ancestry, so step up a level
} else if ( compiled ) {
context = context.parentNode;
} }
selector = selector.slice( tokens.shift().value.length ); selector = selector.slice( tokens.shift().value.length );
} }
...@@ -2476,11 +2525,10 @@ function select( selector, context, results, seed ) { ...@@ -2476,11 +2525,10 @@ function select( selector, context, results, seed ) {
} }
} }
} }
}
// Compile and execute a filtering function // Compile and execute a filtering function if one is not provided
// Provide `match` to avoid retokenization if we modified the selector above // Provide `match` to avoid retokenization if we modified the selector above
compile( selector, match )( ( compiled || compile( selector, match ) )(
seed, seed,
context, context,
!documentIsHTML, !documentIsHTML,
...@@ -2488,14 +2536,14 @@ function select( selector, context, results, seed ) { ...@@ -2488,14 +2536,14 @@ function select( selector, context, results, seed ) {
rsibling.test( selector ) && testContext( context.parentNode ) || context rsibling.test( selector ) && testContext( context.parentNode ) || context
); );
return results; return results;
} };
// One-time assignments // One-time assignments
// Sort stability // Sort stability
support.sortStable = expando.split("").sort( sortOrder ).join("") === expando; support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
// Support: Chrome<14 // Support: Chrome 14-35+
// Always assume duplicates if they aren't passed to the comparison function // Always assume duplicates if they aren't passed to the comparison function
support.detectDuplicates = !!hasDuplicate; support.detectDuplicates = !!hasDuplicate;
...@@ -2704,7 +2752,7 @@ var rootjQuery, ...@@ -2704,7 +2752,7 @@ var rootjQuery,
if ( match[1] ) { if ( match[1] ) {
context = context instanceof jQuery ? context[0] : context; context = context instanceof jQuery ? context[0] : context;
// scripts is true for back-compat // Option to run scripts is true for back-compat
// Intentionally let the error be thrown if parseHTML is not present // Intentionally let the error be thrown if parseHTML is not present
jQuery.merge( this, jQuery.parseHTML( jQuery.merge( this, jQuery.parseHTML(
match[1], match[1],
...@@ -2732,8 +2780,8 @@ var rootjQuery, ...@@ -2732,8 +2780,8 @@ var rootjQuery,
} else { } else {
elem = document.getElementById( match[2] ); elem = document.getElementById( match[2] );
// Check parentNode to catch when Blackberry 4.6 returns // Support: Blackberry 4.6
// nodes that are no longer in the document #6963 // gEBID returns nodes no longer in the document (#6963)
if ( elem && elem.parentNode ) { if ( elem && elem.parentNode ) {
// Inject the element directly into the jQuery object // Inject the element directly into the jQuery object
this.length = 1; this.length = 1;
...@@ -2786,7 +2834,7 @@ rootjQuery = jQuery( document ); ...@@ -2786,7 +2834,7 @@ rootjQuery = jQuery( document );
var rparentsprev = /^(?:parents|prev(?:Until|All))/, var rparentsprev = /^(?:parents|prev(?:Until|All))/,
// methods guaranteed to produce a unique set when starting from a unique set // Methods guaranteed to produce a unique set when starting from a unique set
guaranteedUnique = { guaranteedUnique = {
children: true, children: true,
contents: true, contents: true,
...@@ -2866,8 +2914,7 @@ jQuery.fn.extend({ ...@@ -2866,8 +2914,7 @@ jQuery.fn.extend({
return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched ); return this.pushStack( matched.length > 1 ? jQuery.unique( matched ) : matched );
}, },
// Determine the position of an element within // Determine the position of an element within the set
// the matched set of elements
index: function( elem ) { index: function( elem ) {
// No argument, return index in parent // No argument, return index in parent
...@@ -2875,7 +2922,7 @@ jQuery.fn.extend({ ...@@ -2875,7 +2922,7 @@ jQuery.fn.extend({
return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1; return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
} }
// index in selector // Index in selector
if ( typeof elem === "string" ) { if ( typeof elem === "string" ) {
return indexOf.call( jQuery( elem ), this[ 0 ] ); return indexOf.call( jQuery( elem ), this[ 0 ] );
} }
...@@ -3291,7 +3338,7 @@ jQuery.extend({ ...@@ -3291,7 +3338,7 @@ jQuery.extend({
progressValues, progressContexts, resolveContexts; progressValues, progressContexts, resolveContexts;
// add listeners to Deferred subordinates; treat others as resolved // Add listeners to Deferred subordinates; treat others as resolved
if ( length > 1 ) { if ( length > 1 ) {
progressValues = new Array( length ); progressValues = new Array( length );
progressContexts = new Array( length ); progressContexts = new Array( length );
...@@ -3308,7 +3355,7 @@ jQuery.extend({ ...@@ -3308,7 +3355,7 @@ jQuery.extend({
} }
} }
// if we're not waiting on anything, resolve the master // If we're not waiting on anything, resolve the master
if ( !remaining ) { if ( !remaining ) {
deferred.resolveWith( resolveContexts, resolveValues ); deferred.resolveWith( resolveContexts, resolveValues );
} }
...@@ -3365,8 +3412,9 @@ jQuery.extend({ ...@@ -3365,8 +3412,9 @@ jQuery.extend({
readyList.resolveWith( document, [ jQuery ] ); readyList.resolveWith( document, [ jQuery ] );
// Trigger any bound ready events // Trigger any bound ready events
if ( jQuery.fn.trigger ) { if ( jQuery.fn.triggerHandler ) {
jQuery( document ).trigger("ready").off("ready"); jQuery( document ).triggerHandler( "ready" );
jQuery( document ).off( "ready" );
} }
} }
}); });
...@@ -3386,7 +3434,7 @@ jQuery.ready.promise = function( obj ) { ...@@ -3386,7 +3434,7 @@ jQuery.ready.promise = function( obj ) {
readyList = jQuery.Deferred(); readyList = jQuery.Deferred();
// Catch cases where $(document).ready() is called after the browser event has already occurred. // Catch cases where $(document).ready() is called after the browser event has already occurred.
// we once tried to use readyState "interactive" here, but it caused issues like the one // We once tried to use readyState "interactive" here, but it caused issues like the one
// discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15 // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
if ( document.readyState === "complete" ) { if ( document.readyState === "complete" ) {
// Handle it asynchronously to allow scripts the opportunity to delay ready // Handle it asynchronously to allow scripts the opportunity to delay ready
...@@ -3480,7 +3528,7 @@ jQuery.acceptData = function( owner ) { ...@@ -3480,7 +3528,7 @@ jQuery.acceptData = function( owner ) {
function Data() { function Data() {
// Support: Android < 4, // Support: Android<4,
// Old WebKit does not have Object.preventExtensions/freeze method, // Old WebKit does not have Object.preventExtensions/freeze method,
// return new empty object instead with no [[set]] accessor // return new empty object instead with no [[set]] accessor
Object.defineProperty( this.cache = {}, 0, { Object.defineProperty( this.cache = {}, 0, {
...@@ -3489,7 +3537,7 @@ function Data() { ...@@ -3489,7 +3537,7 @@ function Data() {
} }
}); });
this.expando = jQuery.expando + Math.random(); this.expando = jQuery.expando + Data.uid++;
} }
Data.uid = 1; Data.uid = 1;
...@@ -3517,7 +3565,7 @@ Data.prototype = { ...@@ -3517,7 +3565,7 @@ Data.prototype = {
descriptor[ this.expando ] = { value: unlock }; descriptor[ this.expando ] = { value: unlock };
Object.defineProperties( owner, descriptor ); Object.defineProperties( owner, descriptor );
// Support: Android < 4 // Support: Android<4
// Fallback to a less secure definition // Fallback to a less secure definition
} catch ( e ) { } catch ( e ) {
descriptor[ this.expando ] = unlock; descriptor[ this.expando ] = unlock;
...@@ -3657,17 +3705,16 @@ var data_user = new Data(); ...@@ -3657,17 +3705,16 @@ var data_user = new Data();
/* // Implementation Summary
Implementation Summary //
// 1. Enforce API surface and semantic compatibility with 1.9.x branch
1. Enforce API surface and semantic compatibility with 1.9.x branch // 2. Improve the module's maintainability by reducing the storage
2. Improve the module's maintainability by reducing the storage // paths to a single mechanism.
paths to a single mechanism. // 3. Use the same single mechanism to support "private" and "user" data.
3. Use the same single mechanism to support "private" and "user" data. // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData) // 5. Avoid exposing implementation details on user objects (eg. expando properties)
5. Avoid exposing implementation details on user objects (eg. expando properties) // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
6. Provide a clear path for implementation upgrade to WeakMap in 2014
*/
var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/, var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
rmultiDash = /([A-Z])/g; rmultiDash = /([A-Z])/g;
...@@ -3738,13 +3785,17 @@ jQuery.fn.extend({ ...@@ -3738,13 +3785,17 @@ jQuery.fn.extend({
if ( elem.nodeType === 1 && !data_priv.get( elem, "hasDataAttrs" ) ) { if ( elem.nodeType === 1 && !data_priv.get( elem, "hasDataAttrs" ) ) {
i = attrs.length; i = attrs.length;
while ( i-- ) { while ( i-- ) {
name = attrs[ i ].name;
// Support: IE11+
// The attrs elements can be null (#14894)
if ( attrs[ i ] ) {
name = attrs[ i ].name;
if ( name.indexOf( "data-" ) === 0 ) { if ( name.indexOf( "data-" ) === 0 ) {
name = jQuery.camelCase( name.slice(5) ); name = jQuery.camelCase( name.slice(5) );
dataAttr( elem, name, data[ name ] ); dataAttr( elem, name, data[ name ] );
} }
} }
}
data_priv.set( elem, "hasDataAttrs", true ); data_priv.set( elem, "hasDataAttrs", true );
} }
} }
...@@ -3868,7 +3919,7 @@ jQuery.extend({ ...@@ -3868,7 +3919,7 @@ jQuery.extend({
queue.unshift( "inprogress" ); queue.unshift( "inprogress" );
} }
// clear up the last queue stop function // Clear up the last queue stop function
delete hooks.stop; delete hooks.stop;
fn.call( elem, next, hooks ); fn.call( elem, next, hooks );
} }
...@@ -3878,7 +3929,7 @@ jQuery.extend({ ...@@ -3878,7 +3929,7 @@ jQuery.extend({
} }
}, },
// not intended for public consumption - generates a queueHooks object, or returns the current one // Not public - generate a queueHooks object, or return the current one
_queueHooks: function( elem, type ) { _queueHooks: function( elem, type ) {
var key = type + "queueHooks"; var key = type + "queueHooks";
return data_priv.get( elem, key ) || data_priv.access( elem, key, { return data_priv.get( elem, key ) || data_priv.access( elem, key, {
...@@ -3908,7 +3959,7 @@ jQuery.fn.extend({ ...@@ -3908,7 +3959,7 @@ jQuery.fn.extend({
this.each(function() { this.each(function() {
var queue = jQuery.queue( this, type, data ); var queue = jQuery.queue( this, type, data );
// ensure a hooks for this queue // Ensure a hooks for this queue
jQuery._queueHooks( this, type ); jQuery._queueHooks( this, type );
if ( type === "fx" && queue[0] !== "inprogress" ) { if ( type === "fx" && queue[0] !== "inprogress" ) {
...@@ -3972,17 +4023,25 @@ var rcheckableType = (/^(?:checkbox|radio)$/i); ...@@ -3972,17 +4023,25 @@ var rcheckableType = (/^(?:checkbox|radio)$/i);
(function() { (function() {
var fragment = document.createDocumentFragment(), var fragment = document.createDocumentFragment(),
div = fragment.appendChild( document.createElement( "div" ) ); div = fragment.appendChild( document.createElement( "div" ) ),
input = document.createElement( "input" );
// #11217 - WebKit loses check when the name is after the checked attribute // Support: Safari<=5.1
div.innerHTML = "<input type='radio' checked='checked' name='t'/>"; // Check state lost if the name is set (#11217)
// Support: Windows Web Apps (WWA)
// `name` and `type` must use .setAttribute for WWA (#14901)
input.setAttribute( "type", "radio" );
input.setAttribute( "checked", "checked" );
input.setAttribute( "name", "t" );
// Support: Safari 5.1, iOS 5.1, Android 4.x, Android 2.3 div.appendChild( input );
// old WebKit doesn't clone checked state correctly in fragments
// Support: Safari<=5.1, Android<4.2
// Older WebKit doesn't clone checked state correctly in fragments
support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked; support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
// Support: IE<=11+
// Make sure textarea (and checkbox) defaultValue is properly cloned // Make sure textarea (and checkbox) defaultValue is properly cloned
// Support: IE9-IE11+
div.innerHTML = "<textarea>x</textarea>"; div.innerHTML = "<textarea>x</textarea>";
support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue; support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
})(); })();
...@@ -3995,7 +4054,7 @@ support.focusinBubbles = "onfocusin" in window; ...@@ -3995,7 +4054,7 @@ support.focusinBubbles = "onfocusin" in window;
var var
rkeyEvent = /^key/, rkeyEvent = /^key/,
rmouseEvent = /^(?:mouse|contextmenu)|click/, rmouseEvent = /^(?:mouse|pointer|contextmenu)|click/,
rfocusMorph = /^(?:focusinfocus|focusoutblur)$/, rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
rtypenamespace = /^([^.]*)(?:\.(.+)|)$/; rtypenamespace = /^([^.]*)(?:\.(.+)|)$/;
...@@ -4360,8 +4419,8 @@ jQuery.event = { ...@@ -4360,8 +4419,8 @@ jQuery.event = {
j = 0; j = 0;
while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) { while ( (handleObj = matched.handlers[ j++ ]) && !event.isImmediatePropagationStopped() ) {
// Triggered event must either 1) have no namespace, or // Triggered event must either 1) have no namespace, or 2) have namespace(s)
// 2) have namespace(s) a subset or equal to those in the bound event (both can have no namespace). // a subset or equal to those in the bound event (both can have no namespace).
if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) { if ( !event.namespace_re || event.namespace_re.test( handleObj.namespace ) ) {
event.handleObj = handleObj; event.handleObj = handleObj;
...@@ -4511,7 +4570,7 @@ jQuery.event = { ...@@ -4511,7 +4570,7 @@ jQuery.event = {
event.target = document; event.target = document;
} }
// Support: Safari 6.0+, Chrome < 28 // Support: Safari 6.0+, Chrome<28
// Target should not be a text node (#504, #13143) // Target should not be a text node (#504, #13143)
if ( event.target.nodeType === 3 ) { if ( event.target.nodeType === 3 ) {
event.target = event.target.parentNode; event.target = event.target.parentNode;
...@@ -4564,7 +4623,7 @@ jQuery.event = { ...@@ -4564,7 +4623,7 @@ jQuery.event = {
// Support: Firefox 20+ // Support: Firefox 20+
// Firefox doesn't alert if the returnValue field is not set. // Firefox doesn't alert if the returnValue field is not set.
if ( event.result !== undefined ) { if ( event.result !== undefined && event.originalEvent ) {
event.originalEvent.returnValue = event.result; event.originalEvent.returnValue = event.result;
} }
} }
...@@ -4615,9 +4674,9 @@ jQuery.Event = function( src, props ) { ...@@ -4615,9 +4674,9 @@ jQuery.Event = function( src, props ) {
// Events bubbling up the document may have been marked as prevented // Events bubbling up the document may have been marked as prevented
// by a handler lower down the tree; reflect the correct value. // by a handler lower down the tree; reflect the correct value.
this.isDefaultPrevented = src.defaultPrevented || this.isDefaultPrevented = src.defaultPrevented ||
// Support: Android < 4.0
src.defaultPrevented === undefined && src.defaultPrevented === undefined &&
src.getPreventDefault && src.getPreventDefault() ? // Support: Android<4.0
src.returnValue === false ?
returnTrue : returnTrue :
returnFalse; returnFalse;
...@@ -4664,7 +4723,14 @@ jQuery.Event.prototype = { ...@@ -4664,7 +4723,14 @@ jQuery.Event.prototype = {
} }
}, },
stopImmediatePropagation: function() { stopImmediatePropagation: function() {
var e = this.originalEvent;
this.isImmediatePropagationStopped = returnTrue; this.isImmediatePropagationStopped = returnTrue;
if ( e && e.stopImmediatePropagation ) {
e.stopImmediatePropagation();
}
this.stopPropagation(); this.stopPropagation();
} }
}; };
...@@ -4673,7 +4739,9 @@ jQuery.Event.prototype = { ...@@ -4673,7 +4739,9 @@ jQuery.Event.prototype = {
// Support: Chrome 15+ // Support: Chrome 15+
jQuery.each({ jQuery.each({
mouseenter: "mouseover", mouseenter: "mouseover",
mouseleave: "mouseout" mouseleave: "mouseout",
pointerenter: "pointerover",
pointerleave: "pointerout"
}, function( orig, fix ) { }, function( orig, fix ) {
jQuery.event.special[ orig ] = { jQuery.event.special[ orig ] = {
delegateType: fix, delegateType: fix,
...@@ -4697,8 +4765,8 @@ jQuery.each({ ...@@ -4697,8 +4765,8 @@ jQuery.each({
}; };
}); });
// Create "bubbling" focus and blur events
// Support: Firefox, Chrome, Safari // Support: Firefox, Chrome, Safari
// Create "bubbling" focus and blur events
if ( !support.focusinBubbles ) { if ( !support.focusinBubbles ) {
jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
...@@ -4851,7 +4919,7 @@ var ...@@ -4851,7 +4919,7 @@ var
// We have to close these tags to support XHTML (#13200) // We have to close these tags to support XHTML (#13200)
wrapMap = { wrapMap = {
// Support: IE 9 // Support: IE9
option: [ 1, "<select multiple='multiple'>", "</select>" ], option: [ 1, "<select multiple='multiple'>", "</select>" ],
thead: [ 1, "<table>", "</table>" ], thead: [ 1, "<table>", "</table>" ],
...@@ -4862,7 +4930,7 @@ var ...@@ -4862,7 +4930,7 @@ var
_default: [ 0, "", "" ] _default: [ 0, "", "" ]
}; };
// Support: IE 9 // Support: IE9
wrapMap.optgroup = wrapMap.option; wrapMap.optgroup = wrapMap.option;
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
...@@ -4952,7 +5020,7 @@ function getAll( context, tag ) { ...@@ -4952,7 +5020,7 @@ function getAll( context, tag ) {
ret; ret;
} }
// Support: IE >= 9 // Fix IE bugs, see support tests
function fixInput( src, dest ) { function fixInput( src, dest ) {
var nodeName = dest.nodeName.toLowerCase(); var nodeName = dest.nodeName.toLowerCase();
...@@ -4972,8 +5040,7 @@ jQuery.extend({ ...@@ -4972,8 +5040,7 @@ jQuery.extend({
clone = elem.cloneNode( true ), clone = elem.cloneNode( true ),
inPage = jQuery.contains( elem.ownerDocument, elem ); inPage = jQuery.contains( elem.ownerDocument, elem );
// Support: IE >= 9 // Fix IE cloning issues
// Fix Cloning issues
if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
!jQuery.isXMLDoc( elem ) ) { !jQuery.isXMLDoc( elem ) ) {
...@@ -5024,8 +5091,8 @@ jQuery.extend({ ...@@ -5024,8 +5091,8 @@ jQuery.extend({
// Add nodes directly // Add nodes directly
if ( jQuery.type( elem ) === "object" ) { if ( jQuery.type( elem ) === "object" ) {
// Support: QtWebKit // Support: QtWebKit, PhantomJS
// jQuery.merge because push.apply(_, arraylike) throws // push.apply(_, arraylike) throws on ancient WebKit
jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem ); jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
// Convert non-html into a text node // Convert non-html into a text node
...@@ -5047,15 +5114,14 @@ jQuery.extend({ ...@@ -5047,15 +5114,14 @@ jQuery.extend({
tmp = tmp.lastChild; tmp = tmp.lastChild;
} }
// Support: QtWebKit // Support: QtWebKit, PhantomJS
// jQuery.merge because push.apply(_, arraylike) throws // push.apply(_, arraylike) throws on ancient WebKit
jQuery.merge( nodes, tmp.childNodes ); jQuery.merge( nodes, tmp.childNodes );
// Remember the top-level container // Remember the top-level container
tmp = fragment.firstChild; tmp = fragment.firstChild;
// Fixes #12346 // Ensure the created nodes are orphaned (#12392)
// Support: Webkit, IE
tmp.textContent = ""; tmp.textContent = "";
} }
} }
...@@ -5098,7 +5164,7 @@ jQuery.extend({ ...@@ -5098,7 +5164,7 @@ jQuery.extend({
}, },
cleanData: function( elems ) { cleanData: function( elems ) {
var data, elem, events, type, key, j, var data, elem, type, key,
special = jQuery.event.special, special = jQuery.event.special,
i = 0; i = 0;
...@@ -5107,9 +5173,8 @@ jQuery.extend({ ...@@ -5107,9 +5173,8 @@ jQuery.extend({
key = elem[ data_priv.expando ]; key = elem[ data_priv.expando ];
if ( key && (data = data_priv.cache[ key ]) ) { if ( key && (data = data_priv.cache[ key ]) ) {
events = Object.keys( data.events || {} ); if ( data.events ) {
if ( events.length ) { for ( type in data.events ) {
for ( j = 0; (type = events[j]) !== undefined; j++ ) {
if ( special[ type ] ) { if ( special[ type ] ) {
jQuery.event.remove( elem, type ); jQuery.event.remove( elem, type );
...@@ -5412,14 +5477,15 @@ var iframe, ...@@ -5412,14 +5477,15 @@ var iframe,
*/ */
// Called only from within defaultDisplay // Called only from within defaultDisplay
function actualDisplay( name, doc ) { function actualDisplay( name, doc ) {
var elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ), var style,
elem = jQuery( doc.createElement( name ) ).appendTo( doc.body ),
// getDefaultComputedStyle might be reliably used only on attached element // getDefaultComputedStyle might be reliably used only on attached element
display = window.getDefaultComputedStyle ? display = window.getDefaultComputedStyle && ( style = window.getDefaultComputedStyle( elem[ 0 ] ) ) ?
// Use of this method is a temporary fix (more like optmization) until something better comes along, // Use of this method is a temporary fix (more like optimization) until something better comes along,
// since it was removed from specification and supported only in FF // since it was removed from specification and supported only in FF
window.getDefaultComputedStyle( elem[ 0 ] ).display : jQuery.css( elem[ 0 ], "display" ); style.display : jQuery.css( elem[ 0 ], "display" );
// We don't have any data stored on the element, // We don't have any data stored on the element,
// so use "detach" method as fast way to get rid of the element // so use "detach" method as fast way to get rid of the element
...@@ -5467,7 +5533,14 @@ var rmargin = (/^margin/); ...@@ -5467,7 +5533,14 @@ var rmargin = (/^margin/);
var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" ); var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
var getStyles = function( elem ) { var getStyles = function( elem ) {
// Support: IE<=11+, Firefox<=30+ (#15098, #14150)
// IE throws on elements created in popups
// FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
if ( elem.ownerDocument.defaultView.opener ) {
return elem.ownerDocument.defaultView.getComputedStyle( elem, null ); return elem.ownerDocument.defaultView.getComputedStyle( elem, null );
}
return window.getComputedStyle( elem, null );
}; };
...@@ -5479,7 +5552,7 @@ function curCSS( elem, name, computed ) { ...@@ -5479,7 +5552,7 @@ function curCSS( elem, name, computed ) {
computed = computed || getStyles( elem ); computed = computed || getStyles( elem );
// Support: IE9 // Support: IE9
// getPropertyValue is only needed for .css('filter') in IE9, see #12537 // getPropertyValue is only needed for .css('filter') (#12537)
if ( computed ) { if ( computed ) {
ret = computed.getPropertyValue( name ) || computed[ name ]; ret = computed.getPropertyValue( name ) || computed[ name ];
} }
...@@ -5525,15 +5598,13 @@ function addGetHookIf( conditionFn, hookFn ) { ...@@ -5525,15 +5598,13 @@ function addGetHookIf( conditionFn, hookFn ) {
return { return {
get: function() { get: function() {
if ( conditionFn() ) { if ( conditionFn() ) {
// Hook not needed (or it's not possible to use it due to missing dependency), // Hook not needed (or it's not possible to use it due
// remove it. // to missing dependency), remove it.
// Since there are no other hooks for marginRight, remove the whole object.
delete this.get; delete this.get;
return; return;
} }
// Hook needed; redefine it so that the support test is not executed again. // Hook needed; redefine it so that the support test is not executed again.
return (this.get = hookFn).apply( this, arguments ); return (this.get = hookFn).apply( this, arguments );
} }
}; };
...@@ -5542,28 +5613,34 @@ function addGetHookIf( conditionFn, hookFn ) { ...@@ -5542,28 +5613,34 @@ function addGetHookIf( conditionFn, hookFn ) {
(function() { (function() {
var pixelPositionVal, boxSizingReliableVal, var pixelPositionVal, boxSizingReliableVal,
// Support: Firefox, Android 2.3 (Prefixed box-sizing versions).
divReset = "padding:0;margin:0;border:0;display:block;-webkit-box-sizing:content-box;" +
"-moz-box-sizing:content-box;box-sizing:content-box",
docElem = document.documentElement, docElem = document.documentElement,
container = document.createElement( "div" ), container = document.createElement( "div" ),
div = document.createElement( "div" ); div = document.createElement( "div" );
if ( !div.style ) {
return;
}
// Support: IE9-11+
// Style of cloned element affects source element cloned (#8908)
div.style.backgroundClip = "content-box"; div.style.backgroundClip = "content-box";
div.cloneNode( true ).style.backgroundClip = ""; div.cloneNode( true ).style.backgroundClip = "";
support.clearCloneStyle = div.style.backgroundClip === "content-box"; support.clearCloneStyle = div.style.backgroundClip === "content-box";
container.style.cssText = "border:0;width:0;height:0;position:absolute;top:0;left:-9999px;" + container.style.cssText = "border:0;width:0;height:0;top:0;left:-9999px;margin-top:1px;" +
"margin-top:1px"; "position:absolute";
container.appendChild( div ); container.appendChild( div );
// Executing both pixelPosition & boxSizingReliable tests require only one layout // Executing both pixelPosition & boxSizingReliable tests require only one layout
// so they're executed at the same time to save the second computation. // so they're executed at the same time to save the second computation.
function computePixelPositionAndBoxSizingReliable() { function computePixelPositionAndBoxSizingReliable() {
// Support: Firefox, Android 2.3 (Prefixed box-sizing versions). div.style.cssText =
div.style.cssText = "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" + // Support: Firefox<29, Android 2.3
"box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;" + // Vendor-prefix box-sizing
"position:absolute;top:1%"; "-webkit-box-sizing:border-box;-moz-box-sizing:border-box;" +
"box-sizing:border-box;display:block;margin-top:1%;top:1%;" +
"border:1px;padding:1px;width:4px;position:absolute";
div.innerHTML = "";
docElem.appendChild( container ); docElem.appendChild( container );
var divStyle = window.getComputedStyle( div, null ); var divStyle = window.getComputedStyle( div, null );
...@@ -5573,10 +5650,12 @@ function addGetHookIf( conditionFn, hookFn ) { ...@@ -5573,10 +5650,12 @@ function addGetHookIf( conditionFn, hookFn ) {
docElem.removeChild( container ); docElem.removeChild( container );
} }
// Use window.getComputedStyle because jsdom on node.js will break without it. // Support: node.js jsdom
// Don't assume that getComputedStyle is a property of the global object
if ( window.getComputedStyle ) { if ( window.getComputedStyle ) {
jQuery.extend(support, { jQuery.extend( support, {
pixelPosition: function() { pixelPosition: function() {
// This test is executed only once but we still do memoizing // This test is executed only once but we still do memoizing
// since we can use the boxSizingReliable pre-computing. // since we can use the boxSizingReliable pre-computing.
// No need to check if the test was already performed, though. // No need to check if the test was already performed, though.
...@@ -5590,6 +5669,7 @@ function addGetHookIf( conditionFn, hookFn ) { ...@@ -5590,6 +5669,7 @@ function addGetHookIf( conditionFn, hookFn ) {
return boxSizingReliableVal; return boxSizingReliableVal;
}, },
reliableMarginRight: function() { reliableMarginRight: function() {
// Support: Android 2.3 // Support: Android 2.3
// Check if div with explicit width and no margin-right incorrectly // Check if div with explicit width and no margin-right incorrectly
// gets computed margin-right based on width of container. (#3333) // gets computed margin-right based on width of container. (#3333)
...@@ -5597,7 +5677,13 @@ function addGetHookIf( conditionFn, hookFn ) { ...@@ -5597,7 +5677,13 @@ function addGetHookIf( conditionFn, hookFn ) {
// This support function is only executed once so no memoizing is needed. // This support function is only executed once so no memoizing is needed.
var ret, var ret,
marginDiv = div.appendChild( document.createElement( "div" ) ); marginDiv = div.appendChild( document.createElement( "div" ) );
marginDiv.style.cssText = div.style.cssText = divReset;
// Reset CSS: box-sizing; display; margin; border; padding
marginDiv.style.cssText = div.style.cssText =
// Support: Firefox<29, Android 2.3
// Vendor-prefix box-sizing
"-webkit-box-sizing:content-box;-moz-box-sizing:content-box;" +
"box-sizing:content-box;display:block;margin:0;border:0;padding:0";
marginDiv.style.marginRight = marginDiv.style.width = "0"; marginDiv.style.marginRight = marginDiv.style.width = "0";
div.style.width = "1px"; div.style.width = "1px";
docElem.appendChild( container ); docElem.appendChild( container );
...@@ -5605,9 +5691,7 @@ function addGetHookIf( conditionFn, hookFn ) { ...@@ -5605,9 +5691,7 @@ function addGetHookIf( conditionFn, hookFn ) {
ret = !parseFloat( window.getComputedStyle( marginDiv, null ).marginRight ); ret = !parseFloat( window.getComputedStyle( marginDiv, null ).marginRight );
docElem.removeChild( container ); docElem.removeChild( container );
div.removeChild( marginDiv );
// Clean up the div for other support tests.
div.innerHTML = "";
return ret; return ret;
} }
...@@ -5639,29 +5723,29 @@ jQuery.swap = function( elem, options, callback, args ) { ...@@ -5639,29 +5723,29 @@ jQuery.swap = function( elem, options, callback, args ) {
var var
// swappable if display is none or starts with table except "table", "table-cell", or "table-caption" // Swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
// see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
rdisplayswap = /^(none|table(?!-c[ea]).+)/, rdisplayswap = /^(none|table(?!-c[ea]).+)/,
rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ), rnumsplit = new RegExp( "^(" + pnum + ")(.*)$", "i" ),
rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ), rrelNum = new RegExp( "^([+-])=(" + pnum + ")", "i" ),
cssShow = { position: "absolute", visibility: "hidden", display: "block" }, cssShow = { position: "absolute", visibility: "hidden", display: "block" },
cssNormalTransform = { cssNormalTransform = {
letterSpacing: 0, letterSpacing: "0",
fontWeight: 400 fontWeight: "400"
}, },
cssPrefixes = [ "Webkit", "O", "Moz", "ms" ]; cssPrefixes = [ "Webkit", "O", "Moz", "ms" ];
// return a css property mapped to a potentially vendor prefixed property // Return a css property mapped to a potentially vendor prefixed property
function vendorPropName( style, name ) { function vendorPropName( style, name ) {
// shortcut for names that are not vendor prefixed // Shortcut for names that are not vendor prefixed
if ( name in style ) { if ( name in style ) {
return name; return name;
} }
// check for vendor prefixed names // Check for vendor prefixed names
var capName = name[0].toUpperCase() + name.slice(1), var capName = name[0].toUpperCase() + name.slice(1),
origName = name, origName = name,
i = cssPrefixes.length; i = cssPrefixes.length;
...@@ -5694,7 +5778,7 @@ function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { ...@@ -5694,7 +5778,7 @@ function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
val = 0; val = 0;
for ( ; i < 4; i += 2 ) { for ( ; i < 4; i += 2 ) {
// both box models exclude margin, so add it if we want it // Both box models exclude margin, so add it if we want it
if ( extra === "margin" ) { if ( extra === "margin" ) {
val += jQuery.css( elem, extra + cssExpand[ i ], true, styles ); val += jQuery.css( elem, extra + cssExpand[ i ], true, styles );
} }
...@@ -5705,15 +5789,15 @@ function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) { ...@@ -5705,15 +5789,15 @@ function augmentWidthOrHeight( elem, name, extra, isBorderBox, styles ) {
val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); val -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
} }
// at this point, extra isn't border nor margin, so remove border // At this point, extra isn't border nor margin, so remove border
if ( extra !== "margin" ) { if ( extra !== "margin" ) {
val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); val -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
} }
} else { } else {
// at this point, extra isn't content, so add padding // At this point, extra isn't content, so add padding
val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles ); val += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
// at this point, extra isn't content nor padding, so add border // At this point, extra isn't content nor padding, so add border
if ( extra !== "padding" ) { if ( extra !== "padding" ) {
val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles ); val += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
} }
...@@ -5731,7 +5815,7 @@ function getWidthOrHeight( elem, name, extra ) { ...@@ -5731,7 +5815,7 @@ function getWidthOrHeight( elem, name, extra ) {
styles = getStyles( elem ), styles = getStyles( elem ),
isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box"; isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
// some non-html elements return undefined for offsetWidth, so check for null/undefined // Some non-html elements return undefined for offsetWidth, so check for null/undefined
// svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285 // svg - https://bugzilla.mozilla.org/show_bug.cgi?id=649285
// MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668 // MathML - https://bugzilla.mozilla.org/show_bug.cgi?id=491668
if ( val <= 0 || val == null ) { if ( val <= 0 || val == null ) {
...@@ -5746,7 +5830,7 @@ function getWidthOrHeight( elem, name, extra ) { ...@@ -5746,7 +5830,7 @@ function getWidthOrHeight( elem, name, extra ) {
return val; return val;
} }
// we need the check for style in case a browser which returns unreliable values // Check for style in case a browser which returns unreliable values
// for getComputedStyle silently falls back to the reliable elem.style // for getComputedStyle silently falls back to the reliable elem.style
valueIsBorderBox = isBorderBox && valueIsBorderBox = isBorderBox &&
( support.boxSizingReliable() || val === elem.style[ name ] ); ( support.boxSizingReliable() || val === elem.style[ name ] );
...@@ -5755,7 +5839,7 @@ function getWidthOrHeight( elem, name, extra ) { ...@@ -5755,7 +5839,7 @@ function getWidthOrHeight( elem, name, extra ) {
val = parseFloat( val ) || 0; val = parseFloat( val ) || 0;
} }
// use the active box-sizing model to add/subtract irrelevant styles // Use the active box-sizing model to add/subtract irrelevant styles
return ( val + return ( val +
augmentWidthOrHeight( augmentWidthOrHeight(
elem, elem,
...@@ -5795,13 +5879,10 @@ function showHide( elements, show ) { ...@@ -5795,13 +5879,10 @@ function showHide( elements, show ) {
values[ index ] = data_priv.access( elem, "olddisplay", defaultDisplay(elem.nodeName) ); values[ index ] = data_priv.access( elem, "olddisplay", defaultDisplay(elem.nodeName) );
} }
} else { } else {
if ( !values[ index ] ) {
hidden = isHidden( elem ); hidden = isHidden( elem );
if ( display && display !== "none" || !hidden ) { if ( display !== "none" || !hidden ) {
data_priv.set( elem, "olddisplay", hidden ? display : jQuery.css(elem, "display") ); data_priv.set( elem, "olddisplay", hidden ? display : jQuery.css( elem, "display" ) );
}
} }
} }
} }
...@@ -5822,12 +5903,14 @@ function showHide( elements, show ) { ...@@ -5822,12 +5903,14 @@ function showHide( elements, show ) {
} }
jQuery.extend({ jQuery.extend({
// Add in style property hooks for overriding the default // Add in style property hooks for overriding the default
// behavior of getting and setting a style property // behavior of getting and setting a style property
cssHooks: { cssHooks: {
opacity: { opacity: {
get: function( elem, computed ) { get: function( elem, computed ) {
if ( computed ) { if ( computed ) {
// We should always get a number back from opacity // We should always get a number back from opacity
var ret = curCSS( elem, "opacity" ); var ret = curCSS( elem, "opacity" );
return ret === "" ? "1" : ret; return ret === "" ? "1" : ret;
...@@ -5840,6 +5923,8 @@ jQuery.extend({ ...@@ -5840,6 +5923,8 @@ jQuery.extend({
cssNumber: { cssNumber: {
"columnCount": true, "columnCount": true,
"fillOpacity": true, "fillOpacity": true,
"flexGrow": true,
"flexShrink": true,
"fontWeight": true, "fontWeight": true,
"lineHeight": true, "lineHeight": true,
"opacity": true, "opacity": true,
...@@ -5853,12 +5938,12 @@ jQuery.extend({ ...@@ -5853,12 +5938,12 @@ jQuery.extend({
// Add in properties whose names you wish to fix before // Add in properties whose names you wish to fix before
// setting or getting the value // setting or getting the value
cssProps: { cssProps: {
// normalize float css property
"float": "cssFloat" "float": "cssFloat"
}, },
// Get and set the style property on a DOM Node // Get and set the style property on a DOM Node
style: function( elem, name, value, extra ) { style: function( elem, name, value, extra ) {
// Don't set styles on text and comment nodes // Don't set styles on text and comment nodes
if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) { if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
return; return;
...@@ -5871,42 +5956,38 @@ jQuery.extend({ ...@@ -5871,42 +5956,38 @@ jQuery.extend({
name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) ); name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( style, origName ) );
// gets hook for the prefixed version // Gets hook for the prefixed version, then unprefixed version
// followed by the unprefixed version
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
// Check if we're setting a value // Check if we're setting a value
if ( value !== undefined ) { if ( value !== undefined ) {
type = typeof value; type = typeof value;
// convert relative number strings (+= or -=) to relative numbers. #7345 // Convert "+=" or "-=" to relative numbers (#7345)
if ( type === "string" && (ret = rrelNum.exec( value )) ) { if ( type === "string" && (ret = rrelNum.exec( value )) ) {
value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) ); value = ( ret[1] + 1 ) * ret[2] + parseFloat( jQuery.css( elem, name ) );
// Fixes bug #9237 // Fixes bug #9237
type = "number"; type = "number";
} }
// Make sure that null and NaN values aren't set. See: #7116 // Make sure that null and NaN values aren't set (#7116)
if ( value == null || value !== value ) { if ( value == null || value !== value ) {
return; return;
} }
// If a number was passed in, add 'px' to the (except for certain CSS properties) // If a number, add 'px' to the (except for certain CSS properties)
if ( type === "number" && !jQuery.cssNumber[ origName ] ) { if ( type === "number" && !jQuery.cssNumber[ origName ] ) {
value += "px"; value += "px";
} }
// Fixes #8908, it can be done more correctly by specifying setters in cssHooks, // Support: IE9-11+
// but it would mean to define eight (for every problematic property) identical functions // background-* props affect original clone's values
if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) { if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
style[ name ] = "inherit"; style[ name ] = "inherit";
} }
// If a hook was provided, use that value, otherwise just set the specified value // If a hook was provided, use that value, otherwise just set the specified value
if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) { if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value, extra )) !== undefined ) {
// Support: Chrome, Safari
// Setting style to blank string required to delete "style: x !important;"
style[ name ] = "";
style[ name ] = value; style[ name ] = value;
} }
...@@ -5928,8 +6009,7 @@ jQuery.extend({ ...@@ -5928,8 +6009,7 @@ jQuery.extend({
// Make sure that we're working with the right name // Make sure that we're working with the right name
name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) ); name = jQuery.cssProps[ origName ] || ( jQuery.cssProps[ origName ] = vendorPropName( elem.style, origName ) );
// gets hook for the prefixed version // Try prefixed name followed by the unprefixed name
// followed by the unprefixed version
hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ]; hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
// If a hook was provided get the computed value from there // If a hook was provided get the computed value from there
...@@ -5942,12 +6022,12 @@ jQuery.extend({ ...@@ -5942,12 +6022,12 @@ jQuery.extend({
val = curCSS( elem, name, styles ); val = curCSS( elem, name, styles );
} }
//convert "normal" to computed value // Convert "normal" to computed value
if ( val === "normal" && name in cssNormalTransform ) { if ( val === "normal" && name in cssNormalTransform ) {
val = cssNormalTransform[ name ]; val = cssNormalTransform[ name ];
} }
// Return, converting to number if forced or a qualifier was provided and val looks numeric // Make numeric if forced or a qualifier was provided and val looks numeric
if ( extra === "" || extra ) { if ( extra === "" || extra ) {
num = parseFloat( val ); num = parseFloat( val );
return extra === true || jQuery.isNumeric( num ) ? num || 0 : val; return extra === true || jQuery.isNumeric( num ) ? num || 0 : val;
...@@ -5960,9 +6040,10 @@ jQuery.each([ "height", "width" ], function( i, name ) { ...@@ -5960,9 +6040,10 @@ jQuery.each([ "height", "width" ], function( i, name ) {
jQuery.cssHooks[ name ] = { jQuery.cssHooks[ name ] = {
get: function( elem, computed, extra ) { get: function( elem, computed, extra ) {
if ( computed ) { if ( computed ) {
// certain elements can have dimension info if we invisibly show them
// however, it must have a current display style that would benefit from this // Certain elements can have dimension info if we invisibly show them
return elem.offsetWidth === 0 && rdisplayswap.test( jQuery.css( elem, "display" ) ) ? // but it must have a current display style that would benefit
return rdisplayswap.test( jQuery.css( elem, "display" ) ) && elem.offsetWidth === 0 ?
jQuery.swap( elem, cssShow, function() { jQuery.swap( elem, cssShow, function() {
return getWidthOrHeight( elem, name, extra ); return getWidthOrHeight( elem, name, extra );
}) : }) :
...@@ -5989,8 +6070,6 @@ jQuery.each([ "height", "width" ], function( i, name ) { ...@@ -5989,8 +6070,6 @@ jQuery.each([ "height", "width" ], function( i, name ) {
jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight, jQuery.cssHooks.marginRight = addGetHookIf( support.reliableMarginRight,
function( elem, computed ) { function( elem, computed ) {
if ( computed ) { if ( computed ) {
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
// Work around by temporarily setting element display to inline-block
return jQuery.swap( elem, { "display": "inline-block" }, return jQuery.swap( elem, { "display": "inline-block" },
curCSS, [ elem, "marginRight" ] ); curCSS, [ elem, "marginRight" ] );
} }
...@@ -6008,7 +6087,7 @@ jQuery.each({ ...@@ -6008,7 +6087,7 @@ jQuery.each({
var i = 0, var i = 0,
expanded = {}, expanded = {},
// assumes a single number if not a string // Assumes a single number if not a string
parts = typeof value === "string" ? value.split(" ") : [ value ]; parts = typeof value === "string" ? value.split(" ") : [ value ];
for ( ; i < 4; i++ ) { for ( ; i < 4; i++ ) {
...@@ -6131,17 +6210,18 @@ Tween.propHooks = { ...@@ -6131,17 +6210,18 @@ Tween.propHooks = {
return tween.elem[ tween.prop ]; return tween.elem[ tween.prop ];
} }
// passing an empty string as a 3rd parameter to .css will automatically // Passing an empty string as a 3rd parameter to .css will automatically
// attempt a parseFloat and fallback to a string if the parse fails // attempt a parseFloat and fallback to a string if the parse fails.
// so, simple values such as "10px" are parsed to Float. // Simple values such as "10px" are parsed to Float;
// complex values such as "rotate(1rad)" are returned as is. // complex values such as "rotate(1rad)" are returned as-is.
result = jQuery.css( tween.elem, tween.prop, "" ); result = jQuery.css( tween.elem, tween.prop, "" );
// Empty strings, null, undefined and "auto" are converted to 0. // Empty strings, null, undefined and "auto" are converted to 0.
return !result || result === "auto" ? 0 : result; return !result || result === "auto" ? 0 : result;
}, },
set: function( tween ) { set: function( tween ) {
// use step hook for back compat - use cssHook if its there - use .style if its // Use step hook for back compat.
// available and use plain properties where available // Use cssHook if its there.
// Use .style if available and use plain properties where available.
if ( jQuery.fx.step[ tween.prop ] ) { if ( jQuery.fx.step[ tween.prop ] ) {
jQuery.fx.step[ tween.prop ]( tween ); jQuery.fx.step[ tween.prop ]( tween );
} else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) { } else if ( tween.elem.style && ( tween.elem.style[ jQuery.cssProps[ tween.prop ] ] != null || jQuery.cssHooks[ tween.prop ] ) ) {
...@@ -6155,7 +6235,6 @@ Tween.propHooks = { ...@@ -6155,7 +6235,6 @@ Tween.propHooks = {
// Support: IE9 // Support: IE9
// Panic based approach to setting things on disconnected nodes // Panic based approach to setting things on disconnected nodes
Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = { Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
set: function( tween ) { set: function( tween ) {
if ( tween.elem.nodeType && tween.elem.parentNode ) { if ( tween.elem.nodeType && tween.elem.parentNode ) {
...@@ -6211,16 +6290,16 @@ var ...@@ -6211,16 +6290,16 @@ var
start = +target || 1; start = +target || 1;
do { do {
// If previous iteration zeroed out, double until we get *something* // If previous iteration zeroed out, double until we get *something*.
// Use a string for doubling factor so we don't accidentally see scale as unchanged below // Use string for doubling so we don't accidentally see scale as unchanged below
scale = scale || ".5"; scale = scale || ".5";
// Adjust and apply // Adjust and apply
start = start / scale; start = start / scale;
jQuery.style( tween.elem, prop, start + unit ); jQuery.style( tween.elem, prop, start + unit );
// Update scale, tolerating zero or NaN from tween.cur() // Update scale, tolerating zero or NaN from tween.cur(),
// And breaking the loop if scale is unchanged or perfect, or if we've just had enough // break the loop if scale is unchanged or perfect, or if we've just had enough
} while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations ); } while ( scale !== (scale = tween.cur() / target) && scale !== 1 && --maxIterations );
} }
...@@ -6252,8 +6331,8 @@ function genFx( type, includeWidth ) { ...@@ -6252,8 +6331,8 @@ function genFx( type, includeWidth ) {
i = 0, i = 0,
attrs = { height: type }; attrs = { height: type };
// if we include width, step value is 1 to do all cssExpand values, // If we include width, step value is 1 to do all cssExpand values,
// if we don't include width, step value is 2 to skip over Left and Right // otherwise step value is 2 to skip over Left and Right
includeWidth = includeWidth ? 1 : 0; includeWidth = includeWidth ? 1 : 0;
for ( ; i < 4 ; i += 2 - includeWidth ) { for ( ; i < 4 ; i += 2 - includeWidth ) {
which = cssExpand[ i ]; which = cssExpand[ i ];
...@@ -6275,7 +6354,7 @@ function createTween( value, prop, animation ) { ...@@ -6275,7 +6354,7 @@ function createTween( value, prop, animation ) {
for ( ; index < length; index++ ) { for ( ; index < length; index++ ) {
if ( (tween = collection[ index ].call( animation, prop, value )) ) { if ( (tween = collection[ index ].call( animation, prop, value )) ) {
// we're done with this property // We're done with this property
return tween; return tween;
} }
} }
...@@ -6283,14 +6362,14 @@ function createTween( value, prop, animation ) { ...@@ -6283,14 +6362,14 @@ function createTween( value, prop, animation ) {
function defaultPrefilter( elem, props, opts ) { function defaultPrefilter( elem, props, opts ) {
/* jshint validthis: true */ /* jshint validthis: true */
var prop, value, toggle, tween, hooks, oldfire, display, var prop, value, toggle, tween, hooks, oldfire, display, checkDisplay,
anim = this, anim = this,
orig = {}, orig = {},
style = elem.style, style = elem.style,
hidden = elem.nodeType && isHidden( elem ), hidden = elem.nodeType && isHidden( elem ),
dataShow = data_priv.get( elem, "fxshow" ); dataShow = data_priv.get( elem, "fxshow" );
// handle queue: false promises // Handle queue: false promises
if ( !opts.queue ) { if ( !opts.queue ) {
hooks = jQuery._queueHooks( elem, "fx" ); hooks = jQuery._queueHooks( elem, "fx" );
if ( hooks.unqueued == null ) { if ( hooks.unqueued == null ) {
...@@ -6305,8 +6384,7 @@ function defaultPrefilter( elem, props, opts ) { ...@@ -6305,8 +6384,7 @@ function defaultPrefilter( elem, props, opts ) {
hooks.unqueued++; hooks.unqueued++;
anim.always(function() { anim.always(function() {
// doing this makes sure that the complete handler will be called // Ensure the complete handler is called before this completes
// before this completes
anim.always(function() { anim.always(function() {
hooks.unqueued--; hooks.unqueued--;
if ( !jQuery.queue( elem, "fx" ).length ) { if ( !jQuery.queue( elem, "fx" ).length ) {
...@@ -6316,7 +6394,7 @@ function defaultPrefilter( elem, props, opts ) { ...@@ -6316,7 +6394,7 @@ function defaultPrefilter( elem, props, opts ) {
}); });
} }
// height/width overflow pass // Height/width overflow pass
if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) { if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
// Make sure that nothing sneaks out // Make sure that nothing sneaks out
// Record all 3 overflow attributes because IE9-10 do not // Record all 3 overflow attributes because IE9-10 do not
...@@ -6327,13 +6405,12 @@ function defaultPrefilter( elem, props, opts ) { ...@@ -6327,13 +6405,12 @@ function defaultPrefilter( elem, props, opts ) {
// Set display property to inline-block for height/width // Set display property to inline-block for height/width
// animations on inline elements that are having width/height animated // animations on inline elements that are having width/height animated
display = jQuery.css( elem, "display" ); display = jQuery.css( elem, "display" );
// Get default display if display is currently "none"
if ( display === "none" ) {
display = defaultDisplay( elem.nodeName );
}
if ( display === "inline" &&
jQuery.css( elem, "float" ) === "none" ) {
// Test default display if display is currently "none"
checkDisplay = display === "none" ?
data_priv.get( elem, "olddisplay" ) || defaultDisplay( elem.nodeName ) : display;
if ( checkDisplay === "inline" && jQuery.css( elem, "float" ) === "none" ) {
style.display = "inline-block"; style.display = "inline-block";
} }
} }
...@@ -6363,6 +6440,10 @@ function defaultPrefilter( elem, props, opts ) { ...@@ -6363,6 +6440,10 @@ function defaultPrefilter( elem, props, opts ) {
} }
} }
orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop ); orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
// Any non-fx value stops us from restoring the original display value
} else {
display = undefined;
} }
} }
...@@ -6375,7 +6456,7 @@ function defaultPrefilter( elem, props, opts ) { ...@@ -6375,7 +6456,7 @@ function defaultPrefilter( elem, props, opts ) {
dataShow = data_priv.access( elem, "fxshow", {} ); dataShow = data_priv.access( elem, "fxshow", {} );
} }
// store state if its toggle - enables .stop().toggle() to "reverse" // Store state if its toggle - enables .stop().toggle() to "reverse"
if ( toggle ) { if ( toggle ) {
dataShow.hidden = !hidden; dataShow.hidden = !hidden;
} }
...@@ -6405,6 +6486,10 @@ function defaultPrefilter( elem, props, opts ) { ...@@ -6405,6 +6486,10 @@ function defaultPrefilter( elem, props, opts ) {
} }
} }
} }
// If this is a noop like .hide().hide(), restore an overwritten display value
} else if ( (display === "none" ? defaultDisplay( elem.nodeName ) : display) === "inline" ) {
style.display = display;
} }
} }
...@@ -6431,8 +6516,8 @@ function propFilter( props, specialEasing ) { ...@@ -6431,8 +6516,8 @@ function propFilter( props, specialEasing ) {
value = hooks.expand( value ); value = hooks.expand( value );
delete props[ name ]; delete props[ name ];
// not quite $.extend, this wont overwrite keys already present. // Not quite $.extend, this won't overwrite existing keys.
// also - reusing 'index' from above because we have the correct "name" // Reusing 'index' because we have the correct "name"
for ( index in value ) { for ( index in value ) {
if ( !( index in props ) ) { if ( !( index in props ) ) {
props[ index ] = value[ index ]; props[ index ] = value[ index ];
...@@ -6451,7 +6536,7 @@ function Animation( elem, properties, options ) { ...@@ -6451,7 +6536,7 @@ function Animation( elem, properties, options ) {
index = 0, index = 0,
length = animationPrefilters.length, length = animationPrefilters.length,
deferred = jQuery.Deferred().always( function() { deferred = jQuery.Deferred().always( function() {
// don't match elem in the :animated selector // Don't match elem in the :animated selector
delete tick.elem; delete tick.elem;
}), }),
tick = function() { tick = function() {
...@@ -6460,7 +6545,8 @@ function Animation( elem, properties, options ) { ...@@ -6460,7 +6545,8 @@ function Animation( elem, properties, options ) {
} }
var currentTime = fxNow || createFxNow(), var currentTime = fxNow || createFxNow(),
remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ), remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
// archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497) // Support: Android 2.3
// Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
temp = remaining / animation.duration || 0, temp = remaining / animation.duration || 0,
percent = 1 - temp, percent = 1 - temp,
index = 0, index = 0,
...@@ -6496,7 +6582,7 @@ function Animation( elem, properties, options ) { ...@@ -6496,7 +6582,7 @@ function Animation( elem, properties, options ) {
}, },
stop: function( gotoEnd ) { stop: function( gotoEnd ) {
var index = 0, var index = 0,
// if we are going to the end, we want to run all the tweens // If we are going to the end, we want to run all the tweens
// otherwise we skip this part // otherwise we skip this part
length = gotoEnd ? animation.tweens.length : 0; length = gotoEnd ? animation.tweens.length : 0;
if ( stopped ) { if ( stopped ) {
...@@ -6507,8 +6593,7 @@ function Animation( elem, properties, options ) { ...@@ -6507,8 +6593,7 @@ function Animation( elem, properties, options ) {
animation.tweens[ index ].run( 1 ); animation.tweens[ index ].run( 1 );
} }
// resolve when we played the last frame // Resolve when we played the last frame; otherwise, reject
// otherwise, reject
if ( gotoEnd ) { if ( gotoEnd ) {
deferred.resolveWith( elem, [ animation, gotoEnd ] ); deferred.resolveWith( elem, [ animation, gotoEnd ] );
} else { } else {
...@@ -6590,7 +6675,7 @@ jQuery.speed = function( speed, easing, fn ) { ...@@ -6590,7 +6675,7 @@ jQuery.speed = function( speed, easing, fn ) {
opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration : opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default; opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
// normalize opt.queue - true/undefined/null -> "fx" // Normalize opt.queue - true/undefined/null -> "fx"
if ( opt.queue == null || opt.queue === true ) { if ( opt.queue == null || opt.queue === true ) {
opt.queue = "fx"; opt.queue = "fx";
} }
...@@ -6614,10 +6699,10 @@ jQuery.speed = function( speed, easing, fn ) { ...@@ -6614,10 +6699,10 @@ jQuery.speed = function( speed, easing, fn ) {
jQuery.fn.extend({ jQuery.fn.extend({
fadeTo: function( speed, to, easing, callback ) { fadeTo: function( speed, to, easing, callback ) {
// show any hidden elements after setting opacity to 0 // Show any hidden elements after setting opacity to 0
return this.filter( isHidden ).css( "opacity", 0 ).show() return this.filter( isHidden ).css( "opacity", 0 ).show()
// animate to the value specified // Animate to the value specified
.end().animate({ opacity: to }, speed, easing, callback ); .end().animate({ opacity: to }, speed, easing, callback );
}, },
animate: function( prop, speed, easing, callback ) { animate: function( prop, speed, easing, callback ) {
...@@ -6680,9 +6765,9 @@ jQuery.fn.extend({ ...@@ -6680,9 +6765,9 @@ jQuery.fn.extend({
} }
} }
// start the next in the queue if the last step wasn't forced // Start the next in the queue if the last step wasn't forced.
// timers currently will call their complete callbacks, which will dequeue // Timers currently will call their complete callbacks, which
// but only if they were gotoEnd // will dequeue but only if they were gotoEnd.
if ( dequeue || !gotoEnd ) { if ( dequeue || !gotoEnd ) {
jQuery.dequeue( this, type ); jQuery.dequeue( this, type );
} }
...@@ -6700,17 +6785,17 @@ jQuery.fn.extend({ ...@@ -6700,17 +6785,17 @@ jQuery.fn.extend({
timers = jQuery.timers, timers = jQuery.timers,
length = queue ? queue.length : 0; length = queue ? queue.length : 0;
// enable finishing flag on private data // Enable finishing flag on private data
data.finish = true; data.finish = true;
// empty the queue first // Empty the queue first
jQuery.queue( this, type, [] ); jQuery.queue( this, type, [] );
if ( hooks && hooks.stop ) { if ( hooks && hooks.stop ) {
hooks.stop.call( this, true ); hooks.stop.call( this, true );
} }
// look for any active animations, and finish them // Look for any active animations, and finish them
for ( index = timers.length; index--; ) { for ( index = timers.length; index--; ) {
if ( timers[ index ].elem === this && timers[ index ].queue === type ) { if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
timers[ index ].anim.stop( true ); timers[ index ].anim.stop( true );
...@@ -6718,14 +6803,14 @@ jQuery.fn.extend({ ...@@ -6718,14 +6803,14 @@ jQuery.fn.extend({
} }
} }
// look for any animations in the old queue and finish them // Look for any animations in the old queue and finish them
for ( index = 0; index < length; index++ ) { for ( index = 0; index < length; index++ ) {
if ( queue[ index ] && queue[ index ].finish ) { if ( queue[ index ] && queue[ index ].finish ) {
queue[ index ].finish.call( this ); queue[ index ].finish.call( this );
} }
} }
// turn off finishing flag // Turn off finishing flag
delete data.finish; delete data.finish;
}); });
} }
...@@ -6828,21 +6913,21 @@ jQuery.fn.delay = function( time, type ) { ...@@ -6828,21 +6913,21 @@ jQuery.fn.delay = function( time, type ) {
input.type = "checkbox"; input.type = "checkbox";
// Support: iOS 5.1, Android 4.x, Android 2.3 // Support: iOS<=5.1, Android<=4.2+
// Check the default checkbox/radio value ("" on old WebKit; "on" elsewhere) // Default value for a checkbox should be "on"
support.checkOn = input.value !== ""; support.checkOn = input.value !== "";
// Must access the parent to make an option select properly // Support: IE<=11+
// Support: IE9, IE10 // Must access selectedIndex to make default options select
support.optSelected = opt.selected; support.optSelected = opt.selected;
// Make sure that the options inside disabled selects aren't marked as disabled // Support: Android<=2.3
// (WebKit marks them as disabled) // Options inside disabled selects are incorrectly marked as disabled
select.disabled = true; select.disabled = true;
support.optDisabled = !opt.disabled; support.optDisabled = !opt.disabled;
// Check if an input maintains its value after becoming a radio // Support: IE<=11+
// Support: IE9, IE10 // An input loses its value after becoming a radio
input = document.createElement( "input" ); input = document.createElement( "input" );
input.value = "t"; input.value = "t";
input.type = "radio"; input.type = "radio";
...@@ -6939,8 +7024,6 @@ jQuery.extend({ ...@@ -6939,8 +7024,6 @@ jQuery.extend({
set: function( elem, value ) { set: function( elem, value ) {
if ( !support.radioValue && value === "radio" && if ( !support.radioValue && value === "radio" &&
jQuery.nodeName( elem, "input" ) ) { jQuery.nodeName( elem, "input" ) ) {
// Setting the type on a radio button after the value resets the value in IE6-9
// Reset value to default in case type is set after value during creation
var val = elem.value; var val = elem.value;
elem.setAttribute( "type", value ); elem.setAttribute( "type", value );
if ( val ) { if ( val ) {
...@@ -7010,7 +7093,7 @@ jQuery.extend({ ...@@ -7010,7 +7093,7 @@ jQuery.extend({
var ret, hooks, notxml, var ret, hooks, notxml,
nType = elem.nodeType; nType = elem.nodeType;
// don't get/set properties on text, comment and attribute nodes // Don't get/set properties on text, comment and attribute nodes
if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
return; return;
} }
...@@ -7046,8 +7129,6 @@ jQuery.extend({ ...@@ -7046,8 +7129,6 @@ jQuery.extend({
} }
}); });
// Support: IE9+
// Selectedness for an option in an optgroup can be inaccurate
if ( !support.optSelected ) { if ( !support.optSelected ) {
jQuery.propHooks.selected = { jQuery.propHooks.selected = {
get: function( elem ) { get: function( elem ) {
...@@ -7155,7 +7236,7 @@ jQuery.fn.extend({ ...@@ -7155,7 +7236,7 @@ jQuery.fn.extend({
} }
} }
// only assign if different to avoid unneeded rendering. // Only assign if different to avoid unneeded rendering.
finalValue = value ? jQuery.trim( cur ) : ""; finalValue = value ? jQuery.trim( cur ) : "";
if ( elem.className !== finalValue ) { if ( elem.className !== finalValue ) {
elem.className = finalValue; elem.className = finalValue;
...@@ -7182,14 +7263,14 @@ jQuery.fn.extend({ ...@@ -7182,14 +7263,14 @@ jQuery.fn.extend({
return this.each(function() { return this.each(function() {
if ( type === "string" ) { if ( type === "string" ) {
// toggle individual class names // Toggle individual class names
var className, var className,
i = 0, i = 0,
self = jQuery( this ), self = jQuery( this ),
classNames = value.match( rnotwhite ) || []; classNames = value.match( rnotwhite ) || [];
while ( (className = classNames[ i++ ]) ) { while ( (className = classNames[ i++ ]) ) {
// check each className given, space separated list // Check each className given, space separated list
if ( self.hasClass( className ) ) { if ( self.hasClass( className ) ) {
self.removeClass( className ); self.removeClass( className );
} else { } else {
...@@ -7204,7 +7285,7 @@ jQuery.fn.extend({ ...@@ -7204,7 +7285,7 @@ jQuery.fn.extend({
data_priv.set( this, "__className__", this.className ); data_priv.set( this, "__className__", this.className );
} }
// If the element has a class name or if we're passed "false", // If the element has a class name or if we're passed `false`,
// then remove the whole classname (if there was one, the above saved it). // then remove the whole classname (if there was one, the above saved it).
// Otherwise bring back whatever was previously saved (if anything), // Otherwise bring back whatever was previously saved (if anything),
// falling back to the empty string if nothing was stored. // falling back to the empty string if nothing was stored.
...@@ -7248,9 +7329,9 @@ jQuery.fn.extend({ ...@@ -7248,9 +7329,9 @@ jQuery.fn.extend({
ret = elem.value; ret = elem.value;
return typeof ret === "string" ? return typeof ret === "string" ?
// handle most common string cases // Handle most common string cases
ret.replace(rreturn, "") : ret.replace(rreturn, "") :
// handle cases where value is null/undef or number // Handle cases where value is null/undef or number
ret == null ? "" : ret; ret == null ? "" : ret;
} }
...@@ -7297,6 +7378,16 @@ jQuery.fn.extend({ ...@@ -7297,6 +7378,16 @@ jQuery.fn.extend({
jQuery.extend({ jQuery.extend({
valHooks: { valHooks: {
option: {
get: function( elem ) {
var val = jQuery.find.attr( elem, "value" );
return val != null ?
val :
// Support: IE10-11+
// option.text throws exceptions (#14686, #14858)
jQuery.trim( jQuery.text( elem ) );
}
},
select: { select: {
get: function( elem ) { get: function( elem ) {
var value, option, var value, option,
...@@ -7343,12 +7434,12 @@ jQuery.extend({ ...@@ -7343,12 +7434,12 @@ jQuery.extend({
while ( i-- ) { while ( i-- ) {
option = options[ i ]; option = options[ i ];
if ( (option.selected = jQuery.inArray( jQuery(option).val(), values ) >= 0) ) { if ( (option.selected = jQuery.inArray( option.value, values ) >= 0) ) {
optionSet = true; optionSet = true;
} }
} }
// force browsers to behave consistently when non-matching value is set // Force browsers to behave consistently when non-matching value is set
if ( !optionSet ) { if ( !optionSet ) {
elem.selectedIndex = -1; elem.selectedIndex = -1;
} }
...@@ -7369,8 +7460,6 @@ jQuery.each([ "radio", "checkbox" ], function() { ...@@ -7369,8 +7460,6 @@ jQuery.each([ "radio", "checkbox" ], function() {
}; };
if ( !support.checkOn ) { if ( !support.checkOn ) {
jQuery.valHooks[ this ].get = function( elem ) { jQuery.valHooks[ this ].get = function( elem ) {
// Support: Webkit
// "" is returned instead of "on" if a value isn't specified
return elem.getAttribute("value") === null ? "on" : elem.value; return elem.getAttribute("value") === null ? "on" : elem.value;
}; };
} }
...@@ -7452,10 +7541,6 @@ jQuery.parseXML = function( data ) { ...@@ -7452,10 +7541,6 @@ jQuery.parseXML = function( data ) {
var var
// Document location
ajaxLocParts,
ajaxLocation,
rhash = /#.*$/, rhash = /#.*$/,
rts = /([?&])_=[^&]*/, rts = /([?&])_=[^&]*/,
rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg, rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
...@@ -7484,22 +7569,13 @@ var ...@@ -7484,22 +7569,13 @@ var
transports = {}, transports = {},
// Avoid comment-prolog char sequence (#10098); must appease lint and evade compression // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
allTypes = "*/".concat("*"); allTypes = "*/".concat( "*" ),
// #8138, IE may throw an exception when accessing // Document location
// a field from window.location if document.domain has been set ajaxLocation = window.location.href,
try {
ajaxLocation = location.href;
} catch( e ) {
// Use the href attribute of an A element
// since IE will modify it given document.location
ajaxLocation = document.createElement( "a" );
ajaxLocation.href = "";
ajaxLocation = ajaxLocation.href;
}
// Segment location into parts // Segment location into parts
ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || []; ajaxLocParts = rurl.exec( ajaxLocation.toLowerCase() ) || [];
// Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
function addToPrefiltersOrTransports( structure ) { function addToPrefiltersOrTransports( structure ) {
...@@ -7978,7 +8054,8 @@ jQuery.extend({ ...@@ -7978,7 +8054,8 @@ jQuery.extend({
} }
// We can fire global events as of now if asked to // We can fire global events as of now if asked to
fireGlobals = s.global; // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
fireGlobals = jQuery.event && s.global;
// Watch for a new set of requests // Watch for a new set of requests
if ( fireGlobals && jQuery.active++ === 0 ) { if ( fireGlobals && jQuery.active++ === 0 ) {
...@@ -8051,7 +8128,7 @@ jQuery.extend({ ...@@ -8051,7 +8128,7 @@ jQuery.extend({
return jqXHR.abort(); return jqXHR.abort();
} }
// aborting is no longer a cancellation // Aborting is no longer a cancellation
strAbort = "abort"; strAbort = "abort";
// Install callbacks on deferreds // Install callbacks on deferreds
...@@ -8163,8 +8240,7 @@ jQuery.extend({ ...@@ -8163,8 +8240,7 @@ jQuery.extend({
isSuccess = !error; isSuccess = !error;
} }
} else { } else {
// We extract error from statusText // Extract error from statusText and normalize for non-aborts
// then normalize statusText and status for non-aborts
error = statusText; error = statusText;
if ( status || !statusText ) { if ( status || !statusText ) {
statusText = "error"; statusText = "error";
...@@ -8220,7 +8296,7 @@ jQuery.extend({ ...@@ -8220,7 +8296,7 @@ jQuery.extend({
jQuery.each( [ "get", "post" ], function( i, method ) { jQuery.each( [ "get", "post" ], function( i, method ) {
jQuery[ method ] = function( url, data, callback, type ) { jQuery[ method ] = function( url, data, callback, type ) {
// shift arguments if data argument was omitted // Shift arguments if data argument was omitted
if ( jQuery.isFunction( data ) ) { if ( jQuery.isFunction( data ) ) {
type = type || callback; type = type || callback;
callback = data; callback = data;
...@@ -8237,13 +8313,6 @@ jQuery.each( [ "get", "post" ], function( i, method ) { ...@@ -8237,13 +8313,6 @@ jQuery.each( [ "get", "post" ], function( i, method ) {
}; };
}); });
// Attach a bunch of functions for handling common AJAX events
jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) {
jQuery.fn[ type ] = function( fn ) {
return this.on( type, fn );
};
});
jQuery._evalUrl = function( url ) { jQuery._evalUrl = function( url ) {
return jQuery.ajax({ return jQuery.ajax({
...@@ -8461,8 +8530,9 @@ var xhrId = 0, ...@@ -8461,8 +8530,9 @@ var xhrId = 0,
// Support: IE9 // Support: IE9
// Open requests must be manually aborted on unload (#5280) // Open requests must be manually aborted on unload (#5280)
if ( window.ActiveXObject ) { // See https://support.microsoft.com/kb/2856746 for more info
jQuery( window ).on( "unload", function() { if ( window.attachEvent ) {
window.attachEvent( "onunload", function() {
for ( var key in xhrCallbacks ) { for ( var key in xhrCallbacks ) {
xhrCallbacks[ key ](); xhrCallbacks[ key ]();
} }
...@@ -8550,10 +8620,15 @@ jQuery.ajaxTransport(function( options ) { ...@@ -8550,10 +8620,15 @@ jQuery.ajaxTransport(function( options ) {
// Create the abort callback // Create the abort callback
callback = xhrCallbacks[ id ] = callback("abort"); callback = xhrCallbacks[ id ] = callback("abort");
// Do send the request try {
// This may raise an exception which is actually // Do send the request (this may raise an exception)
// handled in jQuery.ajax (so no try/catch here)
xhr.send( options.hasContent && options.data || null ); xhr.send( options.hasContent && options.data || null );
} catch ( e ) {
// #14683: Only rethrow if this hasn't been notified as an error yet
if ( callback ) {
throw e;
}
}
}, },
abort: function() { abort: function() {
...@@ -8760,7 +8835,7 @@ jQuery.fn.load = function( url, params, callback ) { ...@@ -8760,7 +8835,7 @@ jQuery.fn.load = function( url, params, callback ) {
off = url.indexOf(" "); off = url.indexOf(" ");
if ( off >= 0 ) { if ( off >= 0 ) {
selector = url.slice( off ); selector = jQuery.trim( url.slice( off ) );
url = url.slice( 0, off ); url = url.slice( 0, off );
} }
...@@ -8810,6 +8885,16 @@ jQuery.fn.load = function( url, params, callback ) { ...@@ -8810,6 +8885,16 @@ jQuery.fn.load = function( url, params, callback ) {
// Attach a bunch of functions for handling common AJAX events
jQuery.each( [ "ajaxStart", "ajaxStop", "ajaxComplete", "ajaxError", "ajaxSuccess", "ajaxSend" ], function( i, type ) {
jQuery.fn[ type ] = function( fn ) {
return this.on( type, fn );
};
});
jQuery.expr.filters.animated = function( elem ) { jQuery.expr.filters.animated = function( elem ) {
return jQuery.grep(jQuery.timers, function( fn ) { return jQuery.grep(jQuery.timers, function( fn ) {
return elem === fn.elem; return elem === fn.elem;
...@@ -8846,7 +8931,8 @@ jQuery.offset = { ...@@ -8846,7 +8931,8 @@ jQuery.offset = {
calculatePosition = ( position === "absolute" || position === "fixed" ) && calculatePosition = ( position === "absolute" || position === "fixed" ) &&
( curCSSTop + curCSSLeft ).indexOf("auto") > -1; ( curCSSTop + curCSSLeft ).indexOf("auto") > -1;
// Need to be able to calculate position if either top or left is auto and position is either absolute or fixed // Need to be able to calculate position if either
// top or left is auto and position is either absolute or fixed
if ( calculatePosition ) { if ( calculatePosition ) {
curPosition = curElem.position(); curPosition = curElem.position();
curTop = curPosition.top; curTop = curPosition.top;
...@@ -8903,8 +8989,8 @@ jQuery.fn.extend({ ...@@ -8903,8 +8989,8 @@ jQuery.fn.extend({
return box; return box;
} }
// Support: BlackBerry 5, iOS 3 (original iPhone)
// If we don't have gBCR, just use 0,0 rather than error // If we don't have gBCR, just use 0,0 rather than error
// BlackBerry 5, iOS 3 (original iPhone)
if ( typeof elem.getBoundingClientRect !== strundefined ) { if ( typeof elem.getBoundingClientRect !== strundefined ) {
box = elem.getBoundingClientRect(); box = elem.getBoundingClientRect();
} }
...@@ -8926,7 +9012,7 @@ jQuery.fn.extend({ ...@@ -8926,7 +9012,7 @@ jQuery.fn.extend({
// Fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent // Fixed elements are offset from window (parentOffset = {top:0, left: 0}, because it is its only offset parent
if ( jQuery.css( elem, "position" ) === "fixed" ) { if ( jQuery.css( elem, "position" ) === "fixed" ) {
// We assume that getBoundingClientRect is available when computed position is fixed // Assume getBoundingClientRect is there when computed position is fixed
offset = elem.getBoundingClientRect(); offset = elem.getBoundingClientRect();
} else { } else {
...@@ -8989,16 +9075,18 @@ jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( ...@@ -8989,16 +9075,18 @@ jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function(
}; };
}); });
// Support: Safari<7+, Chrome<37+
// Add the top/left cssHooks using jQuery.fn.position // Add the top/left cssHooks using jQuery.fn.position
// Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084 // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
// getComputedStyle returns percent when specified for top/left/bottom/right // Blink bug: https://code.google.com/p/chromium/issues/detail?id=229280
// rather than make the css module depend on the offset module, we just check for it here // getComputedStyle returns percent when specified for top/left/bottom/right;
// rather than make the css module depend on the offset module, just check for it here
jQuery.each( [ "top", "left" ], function( i, prop ) { jQuery.each( [ "top", "left" ], function( i, prop ) {
jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition, jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
function( elem, computed ) { function( elem, computed ) {
if ( computed ) { if ( computed ) {
computed = curCSS( elem, prop ); computed = curCSS( elem, prop );
// if curCSS returns percentage, fallback to offset // If curCSS returns percentage, fallback to offset
return rnumnonpx.test( computed ) ? return rnumnonpx.test( computed ) ?
jQuery( elem ).position()[ prop ] + "px" : jQuery( elem ).position()[ prop ] + "px" :
computed; computed;
...@@ -9011,7 +9099,7 @@ jQuery.each( [ "top", "left" ], function( i, prop ) { ...@@ -9011,7 +9099,7 @@ jQuery.each( [ "top", "left" ], function( i, prop ) {
// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) { jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
// margin is only for outerHeight, outerWidth // Margin is only for outerHeight, outerWidth
jQuery.fn[ funcName ] = function( margin, value ) { jQuery.fn[ funcName ] = function( margin, value ) {
var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ), var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" ); extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
...@@ -9068,6 +9156,12 @@ jQuery.fn.andSelf = jQuery.fn.addBack; ...@@ -9068,6 +9156,12 @@ jQuery.fn.andSelf = jQuery.fn.addBack;
// derived from file names, and jQuery is normally delivered in a lowercase // derived from file names, and jQuery is normally delivered in a lowercase
// file name. Do this after creating the global so that if an AMD module wants // file name. Do this after creating the global so that if an AMD module wants
// to call noConflict to hide this version of jQuery, it will work. // to call noConflict to hide this version of jQuery, it will work.
// Note that for maximum portability, libraries that are not jQuery should
// declare themselves as anonymous modules, and avoid setting a global if an
// AMD loader is present. jQuery is a special case. For more information, see
// https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
if ( typeof define === "function" && define.amd ) { if ( typeof define === "function" && define.amd ) {
define( "jquery", [], function() { define( "jquery", [], function() {
return jQuery; return jQuery;
...@@ -9096,8 +9190,8 @@ jQuery.noConflict = function( deep ) { ...@@ -9096,8 +9190,8 @@ jQuery.noConflict = function( deep ) {
return jQuery; return jQuery;
}; };
// Expose jQuery and $ identifiers, even in // Expose jQuery and $ identifiers, even in AMD
// AMD (#7102#comment:10, https://github.com/jquery/jquery/pull/557) // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
// and CommonJS for browser emulators (#13566) // and CommonJS for browser emulators (#13566)
if ( typeof noGlobal === strundefined ) { if ( typeof noGlobal === strundefined ) {
window.jQuery = window.$ = jQuery; window.jQuery = window.$ = jQuery;
......
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