mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Query now throws no warnings under strict mode in Firefox (ticket #922). In fixing this, revision [1771] was discovered and reverted (no API changes are being added in at this time), and a couple un-functioning test cases were fixed (array comparisions were being done for objects).
This commit is contained in:
parent
e95a6cc746
commit
74a8e20623
@ -171,7 +171,7 @@ function ok(a, msg) {
|
||||
*/
|
||||
function isSet(a, b, msg) {
|
||||
var ret = true;
|
||||
if ( a && b && a.length == b.length ) {
|
||||
if ( a && b && a.length != undefined && a.length == b.length ) {
|
||||
for ( var i = 0; i < a.length; i++ )
|
||||
if ( a[i] != b[i] )
|
||||
ret = false;
|
||||
@ -183,8 +183,30 @@ function isSet(a, b, msg) {
|
||||
_config.Test.push( [ ret, msg ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that two objects are equivalent
|
||||
*/
|
||||
function isObj(a, b, msg) {
|
||||
var ret = true;
|
||||
|
||||
if ( a && b ) {
|
||||
for ( var i in a )
|
||||
if ( a[i] != b[i] )
|
||||
ret = false;
|
||||
|
||||
for ( i in b )
|
||||
if ( a[i] != b[i] )
|
||||
ret = false;
|
||||
} else
|
||||
ret = false;
|
||||
|
||||
_config.Test.push( [ ret, msg ] );
|
||||
}
|
||||
|
||||
function serialArray( a ) {
|
||||
var r = [];
|
||||
|
||||
if ( a && a.length )
|
||||
for ( var i = 0; i < a.length; i++ ) {
|
||||
var str = a[i].nodeName;
|
||||
if ( str ) {
|
||||
|
@ -129,7 +129,7 @@ jQuery.event = {
|
||||
|
||||
// Handle triggering a single element
|
||||
else {
|
||||
var val, ret, fn = jQuery.isFunction( element[ type ] );
|
||||
var val, ret, fn = jQuery.isFunction( element[ type ] || null );
|
||||
|
||||
// Pass along a fake event
|
||||
data.unshift( this.fix({ type: type, target: element }) );
|
||||
@ -146,19 +146,18 @@ jQuery.event = {
|
||||
},
|
||||
|
||||
handle: function(event) {
|
||||
// returned undefined or false
|
||||
var val;
|
||||
|
||||
// Handle the second event of a trigger and when
|
||||
// an event is called after a page has unloaded
|
||||
if ( typeof jQuery == "undefined" || jQuery.event.triggered ) return;
|
||||
if ( typeof jQuery == "undefined" || jQuery.event.triggered )
|
||||
return val;
|
||||
|
||||
// Empty object is for triggered events with no data
|
||||
event = jQuery.event.fix( event || window.event || {} );
|
||||
|
||||
// returned undefined or false
|
||||
var returnValue;
|
||||
|
||||
var c = this.$events[event.type];
|
||||
|
||||
var args = [].slice.call( arguments, 1 );
|
||||
var c = this.$events[event.type], args = [].slice.call( arguments, 1 );
|
||||
args.unshift( event );
|
||||
|
||||
for ( var j in c ) {
|
||||
@ -170,14 +169,16 @@ jQuery.event = {
|
||||
if ( c[j].apply( this, args ) === false ) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
returnValue = false;
|
||||
val = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Clean up added properties in IE to prevent memory leak
|
||||
if (jQuery.browser.msie) event.target = event.preventDefault = event.stopPropagation = event.handler = event.data = null;
|
||||
if (jQuery.browser.msie)
|
||||
event.target = event.preventDefault = event.stopPropagation =
|
||||
event.handler = event.data = null;
|
||||
|
||||
return returnValue;
|
||||
return val;
|
||||
},
|
||||
|
||||
fix: function(event) {
|
||||
@ -415,7 +416,7 @@ jQuery.fn.extend({
|
||||
|
||||
return this.click(function(e) {
|
||||
// Figure out which function to execute
|
||||
this.lastToggle = this.lastToggle == 0 ? 1 : 0;
|
||||
this.lastToggle = 0 == this.lastToggle ? 1 : 0;
|
||||
|
||||
// Make sure that clicks stop
|
||||
e.preventDefault();
|
||||
|
20
src/jquery/coreTest.js
vendored
20
src/jquery/coreTest.js
vendored
@ -363,7 +363,7 @@ test("append(String|Element|Array<Element>|jQuery)", function() {
|
||||
ok( $('#select3').append('<option value="appendTest">Append Test</option>').find('option:last-child').attr('value') == 'appendTest', 'Appending html options to select element');
|
||||
|
||||
reset();
|
||||
expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
|
||||
var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
|
||||
$('#sap').append(document.getElementById('first'));
|
||||
ok( expected == $('#sap').text(), "Check for appending of element" );
|
||||
|
||||
@ -422,7 +422,7 @@ test("appendTo(String|Element|Array<Element>|jQuery)", function() {
|
||||
ok( $('<option value="appendTest">Append Test</option>').appendTo('#select3').parent().find('option:last-child').attr('value') == 'appendTest', 'Appending html options to select element');
|
||||
|
||||
reset();
|
||||
expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
|
||||
var expected = "This link has class=\"blog\": Simon Willison's WeblogTry them out:";
|
||||
$(document.getElementById('first')).appendTo('#sap');
|
||||
ok( expected == $('#sap').text(), "Check for appending of element" );
|
||||
|
||||
@ -449,7 +449,7 @@ test("prepend(String|Element|Array<Element>|jQuery)", function() {
|
||||
ok( $('#select3').prepend('<option value="prependTest">Prepend Test</option>').find('option:first-child').attr('value') == 'prependTest', 'Prepending html options to select element');
|
||||
|
||||
reset();
|
||||
expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
|
||||
var expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
|
||||
$('#sap').prepend(document.getElementById('first'));
|
||||
ok( expected == $('#sap').text(), "Check for prepending of element" );
|
||||
|
||||
@ -472,7 +472,7 @@ test("prependTo(String|Element|Array<Element>|jQuery)", function() {
|
||||
ok( $('<option value="prependTest">Prepend Test</option>').prependTo('#select3').parent().find('option:first-child').attr('value') == 'prependTest', 'Prepending html options to select element');
|
||||
|
||||
reset();
|
||||
expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
|
||||
var expected = "Try them out:This link has class=\"blog\": Simon Willison's Weblog";
|
||||
$(document.getElementById('first')).prependTo('#sap');
|
||||
ok( expected == $('#sap').text(), "Check for prepending of element" );
|
||||
|
||||
@ -637,8 +637,8 @@ test("$.extend(Object, Object)", function() {
|
||||
optionsCopy = { xnumber2: 1, xstring2: "x", xxx: "newstring" },
|
||||
merged = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "x", xxx: "newstring" };
|
||||
jQuery.extend(settings, options);
|
||||
isSet( settings, merged, "Check if extended: settings must be extended" );
|
||||
isSet ( options, optionsCopy, "Check if not modified: options must not be modified" );
|
||||
isObj( settings, merged, "Check if extended: settings must be extended" );
|
||||
isObj( options, optionsCopy, "Check if not modified: options must not be modified" );
|
||||
});
|
||||
|
||||
test("$.extend(Object, Object, Object, Object)", function() {
|
||||
@ -651,10 +651,10 @@ test("$.extend(Object, Object, Object, Object)", function() {
|
||||
options2Copy = { xstring2: "xx", xxx: "newstringx" },
|
||||
merged = { xnumber1: 5, xnumber2: 1, xstring1: "peter", xstring2: "xx", xxx: "newstringx" };
|
||||
var settings = jQuery.extend({}, defaults, options1, options2);
|
||||
isSet( settings, merged, "Check if extended: settings must be extended" );
|
||||
isSet ( defaults, defaultsCopy, "Check if not modified: options1 must not be modified" );
|
||||
isSet ( options1, options1Copy, "Check if not modified: options1 must not be modified" );
|
||||
isSet ( options2, options2Copy, "Check if not modified: options2 must not be modified" );
|
||||
isObj( settings, merged, "Check if extended: settings must be extended" );
|
||||
isObj( defaults, defaultsCopy, "Check if not modified: options1 must not be modified" );
|
||||
isObj( options1, options1Copy, "Check if not modified: options1 must not be modified" );
|
||||
isObj( options2, options2Copy, "Check if not modified: options2 must not be modified" );
|
||||
});
|
||||
|
||||
test("val()", function() {
|
||||
|
38
src/jquery/jquery.js
vendored
38
src/jquery/jquery.js
vendored
@ -840,7 +840,7 @@ jQuery.fn = jQuery.prototype = {
|
||||
*/
|
||||
clone: function(deep) {
|
||||
return this.pushStack( jQuery.map( this, function(a){
|
||||
var a = a.cloneNode( deep != undefined ? deep : true );
|
||||
a = a.cloneNode( deep != undefined ? deep : true );
|
||||
a.$events = null; // drop $events expando to avoid firing incorrect events
|
||||
return a;
|
||||
}) );
|
||||
@ -1178,10 +1178,6 @@ jQuery.fn = jQuery.prototype = {
|
||||
* Extend one object with one or more others, returning the original,
|
||||
* modified, object. This is a great utility for simple inheritance.
|
||||
*
|
||||
* There is also an optional collision resolution function. Any time the target and
|
||||
* merged object both contain a key this function is called. This may be used to create
|
||||
* a recursive merge. (See example) Unless you know what this is, you probably don't care.
|
||||
*
|
||||
* @example var settings = { validate: false, limit: 5, name: "foo" };
|
||||
* var options = { validate: true, name: "bar" };
|
||||
* jQuery.extend(settings, options);
|
||||
@ -1194,19 +1190,8 @@ jQuery.fn = jQuery.prototype = {
|
||||
* @result settings == { validate: true, limit: 5, name: "bar" }
|
||||
* @desc Merge defaults and options, without modifying the defaults
|
||||
*
|
||||
* @example var defaults = { validate: false, limit: 5, name: "foo", nested: {depth: false} };
|
||||
* var options = { validate: true, name: "bar", nested: {depth: true} };
|
||||
* var collision_resolver_fn = function(target, mergee) {
|
||||
* // combine nested Objects, in this case the object being merged takes priority
|
||||
* return jQuery.extend({}, target, mergee);
|
||||
* }
|
||||
* var settings = jQuery.extend({}, collision_resolver_fn, defaults, options);
|
||||
* @result settings == { validate: true, limit: 5, name: "bar" }
|
||||
* @desc Recursively merge defaults and options, without modifying the defaults
|
||||
*
|
||||
* @name $.extend
|
||||
* @param Object target The object to extend
|
||||
* @param Function (optional) collision resolution function. Hook to extend the merging behavior of $.extend(). See example.
|
||||
* @param Object prop1 The object that will be merged into the first.
|
||||
* @param Object propN (optional) More objects to merge into the first
|
||||
* @type Object
|
||||
@ -1214,26 +1199,17 @@ jQuery.fn = jQuery.prototype = {
|
||||
*/
|
||||
jQuery.extend = jQuery.fn.extend = function() {
|
||||
// copy reference to target object
|
||||
var resolver, prop, target = arguments[0],
|
||||
a = 1;
|
||||
var target = arguments[0], a = 1;
|
||||
|
||||
// extend jQuery itself if only one argument is passed
|
||||
if ( arguments.length == 1 ) {
|
||||
target = this;
|
||||
a = 0;
|
||||
} else if (jQuery.isFunction(arguments[a])) {
|
||||
resolver = arguments[a++];
|
||||
}
|
||||
|
||||
while (prop = arguments[a++])
|
||||
var prop;
|
||||
while ( (prop = arguments[a++]) != null )
|
||||
// Extend the base object
|
||||
for ( var i in prop ) {
|
||||
if (resolver && target[i] && prop[i]) {
|
||||
target[i] = resolver(target[i], prop[i]);
|
||||
} else {
|
||||
target[i] = prop[i];
|
||||
}
|
||||
}
|
||||
for ( var i in prop ) target[i] = prop[i];
|
||||
|
||||
// Return the modified object
|
||||
return target;
|
||||
@ -1528,7 +1504,7 @@ jQuery.extend({
|
||||
arg = jQuery.makeArray( div.childNodes );
|
||||
}
|
||||
|
||||
if ( arg.length === 0 && !jQuery(arg).is("form, select") )
|
||||
if ( 0 === arg.length && !jQuery(arg).is("form, select") )
|
||||
return;
|
||||
|
||||
if ( arg[0] == undefined || jQuery(arg).is("form, select") )
|
||||
@ -1663,7 +1639,7 @@ jQuery.extend({
|
||||
var r = [], num = jQuery.mergeNum++;
|
||||
|
||||
for ( var i = 0, fl = first.length; i < fl; i++ )
|
||||
if ( first[i].mergeNum != num ) {
|
||||
if ( num != first[i].mergeNum ) {
|
||||
first[i].mergeNum = num;
|
||||
r.push(first[i]);
|
||||
}
|
||||
|
@ -27,8 +27,8 @@ jQuery.extend({
|
||||
contains: "jQuery.fn.text.apply([a]).indexOf(m[3])>=0",
|
||||
|
||||
// Visibility
|
||||
visible: 'a.type!="hidden"&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden"',
|
||||
hidden: 'a.type=="hidden"||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden"',
|
||||
visible: '"hidden"!=a.type&&jQuery.css(a,"display")!="none"&&jQuery.css(a,"visibility")!="hidden"',
|
||||
hidden: '"hidden"==a.type||jQuery.css(a,"display")=="none"||jQuery.css(a,"visibility")=="hidden"',
|
||||
|
||||
// Form attributes
|
||||
enabled: "!a.disabled",
|
||||
@ -37,15 +37,15 @@ jQuery.extend({
|
||||
selected: "a.selected||jQuery.attr(a,'selected')",
|
||||
|
||||
// Form elements
|
||||
text: "a.type=='text'",
|
||||
radio: "a.type=='radio'",
|
||||
checkbox: "a.type=='checkbox'",
|
||||
file: "a.type=='file'",
|
||||
password: "a.type=='password'",
|
||||
submit: "a.type=='submit'",
|
||||
image: "a.type=='image'",
|
||||
reset: "a.type=='reset'",
|
||||
button: 'a.type=="button"||jQuery.nodeName(a,"button")',
|
||||
text: "'text'==a.type",
|
||||
radio: "'radio'==a.type",
|
||||
checkbox: "'checkbox'==a.type",
|
||||
file: "'file'==a.type",
|
||||
password: "'password'==a.type",
|
||||
submit: "'submit'==a.type",
|
||||
image: "'image'==a.type",
|
||||
reset: "'reset'==a.type",
|
||||
button: '"button"==a.type||jQuery.nodeName(a,"button")',
|
||||
input: "/input|select|textarea|button/i.test(a.nodeName)"
|
||||
},
|
||||
".": "jQuery.className.has(a,m[2])",
|
||||
@ -62,7 +62,7 @@ jQuery.extend({
|
||||
_resort: function(m){
|
||||
return ["", m[1], m[3], m[2], m[5]];
|
||||
},
|
||||
_prefix: "z=a[m[3]];if(!z||/href|src/.test(m[3]))z=jQuery.attr(a,m[3]);"
|
||||
_prefix: "var z=a[m[3]];if(!z||/href|src/.test(m[3]))z=jQuery.attr(a,m[3]);"
|
||||
},
|
||||
"[": "jQuery.find(m[2],a).length"
|
||||
},
|
||||
@ -194,7 +194,7 @@ jQuery.extend({
|
||||
// Handle multiple expressions
|
||||
if ( !t.indexOf(",") ) {
|
||||
// Clean the result set
|
||||
if ( ret[0] == context ) ret.shift();
|
||||
if ( context == ret[0] ) ret.shift();
|
||||
|
||||
// Merge the result sets
|
||||
done = jQuery.merge( done, ret );
|
||||
@ -292,7 +292,7 @@ jQuery.extend({
|
||||
ret = [];
|
||||
|
||||
// Remove the root context
|
||||
if ( ret && ret[0] == context )
|
||||
if ( ret && context == ret[0] )
|
||||
ret.shift();
|
||||
|
||||
// And combine the results
|
||||
@ -408,8 +408,9 @@ jQuery.extend({
|
||||
for ( ; cur; cur = cur[dir] ) {
|
||||
if ( cur.nodeType == 1 ) num++;
|
||||
if ( num == result || result == "even" && num % 2 == 0 && num > 1 && cur == elem ||
|
||||
result == "odd" && num % 2 == 1 && cur == elem ) return cur;
|
||||
result == "odd" && num % 2 == 1 && cur == elem ) break;
|
||||
}
|
||||
return cur;
|
||||
},
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user