From df7dfc2404807dce2f97c21782eb3a14ced86d6b Mon Sep 17 00:00:00 2001 From: rjgotten Date: Sun, 17 Oct 2010 08:30:05 -0700 Subject: Check against the type attribute of script elements retrieved through getElementsByTagName() so that only those elements of type "text/javascript" are handled by 'clean'. Fixes #6180: jQuery.clean should not touch script tags that are not of type text/javascript --- src/manipulation.js | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/manipulation.js b/src/manipulation.js index 325f303a8..2cd95ce95 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -146,7 +146,7 @@ jQuery.fn.extend({ return set; } }, - + // keepData is for internal use only--do not document remove: function( selector, keepData ) { for ( var i = 0, elem; (elem = this[i]) != null; i++ ) { @@ -161,7 +161,7 @@ jQuery.fn.extend({ } } } - + return this; }, @@ -177,7 +177,7 @@ jQuery.fn.extend({ elem.removeChild( elem.firstChild ); } } - + return this; }, @@ -322,9 +322,9 @@ jQuery.fn.extend({ } else { results = jQuery.buildFragment( args, this, scripts ); } - + fragment = results.fragment; - + if ( fragment.childNodes.length === 1 ) { first = fragment = fragment.firstChild; } else { @@ -429,18 +429,18 @@ jQuery.each({ jQuery.fn[ name ] = function( selector ) { var ret = [], insert = jQuery( selector ), parent = this.length === 1 && this[0].parentNode; - + if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) { insert[ original ]( this[0] ); return this; - + } else { for ( var i = 0, l = insert.length; i < l; i++ ) { var elems = (i > 0 ? this.clone(true) : this).get(); jQuery( insert[i] )[ original ]( elems ); ret = ret.concat( elems ); } - + return this.pushStack( ret, name, insert.selector ); } }; @@ -528,10 +528,12 @@ jQuery.extend({ for ( i = 0; ret[i]; i++ ) { if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) { scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] ); - + } else { if ( ret[i].nodeType === 1 ) { - ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) ); + var jsTags = jQuery.makeArray( ret[i].getElementsByTagName( "script" )), + jsTags = jQuery.grep(jsTags, function(n, i) { return ( !n.type || n.type.toLowerCase() === "text/javascript" ) }); + ret.splice.apply( ret, [i + 1, 0].concat( jsTags )); } fragment.appendChild( ret[i] ); } @@ -540,22 +542,22 @@ jQuery.extend({ return ret; }, - + cleanData: function( elems ) { var data, id, cache = jQuery.cache, special = jQuery.event.special, deleteExpando = jQuery.support.deleteExpando; - + for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) { continue; } id = elem[ jQuery.expando ]; - + if ( id ) { data = cache[ id ]; - + if ( data && data.events ) { for ( var type in data.events ) { if ( special[ type ] ) { @@ -566,14 +568,14 @@ jQuery.extend({ } } } - + if ( deleteExpando ) { delete elem[ jQuery.expando ]; } else if ( elem.removeAttribute ) { elem.removeAttribute( jQuery.expando ); } - + delete cache[ id ]; } } -- cgit v1.2.3 From 689d63f4871d96300d492fa5ab9d25301070efba Mon Sep 17 00:00:00 2001 From: Jephte CLAIN Date: Tue, 19 Oct 2010 09:29:20 +0400 Subject: Return control of $ and jQuery only if it is really necessary. This make jQuery.noConflict() callable anytime. --- src/core.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/core.js b/src/core.js index 99521d91c..f701a20c1 100644 --- a/src/core.js +++ b/src/core.js @@ -373,9 +373,9 @@ jQuery.extend = jQuery.fn.extend = function() { jQuery.extend({ noConflict: function( deep ) { - window.$ = _$; + if ( window.$ === jQuery ) window.$ = _$; - if ( deep ) { + if ( deep && window.jQuery === jQuery ) { window.jQuery = _jQuery; } -- cgit v1.2.3 From dd79199a08b9b69d139606619b818c429e0540c3 Mon Sep 17 00:00:00 2001 From: Jephte CLAIN Date: Mon, 22 Nov 2010 08:12:12 +0400 Subject: fix to follow current source style --- src/core.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/core.js b/src/core.js index f701a20c1..4cc5eea10 100644 --- a/src/core.js +++ b/src/core.js @@ -373,7 +373,9 @@ jQuery.extend = jQuery.fn.extend = function() { jQuery.extend({ noConflict: function( deep ) { - if ( window.$ === jQuery ) window.$ = _$; + if ( window.$ === jQuery ) { + window.$ = _$; + } if ( deep && window.jQuery === jQuery ) { window.jQuery = _jQuery; -- cgit v1.2.3 From d03d2e9f26f85366ad2e91b9e2c76a249d7bf7be Mon Sep 17 00:00:00 2001 From: Xavi Date: Sun, 9 Jan 2011 19:11:05 -0500 Subject: Bug 7931; Fixed bug that caused scrollTop and scrollLeft setters to return null when called on an empty jquery object --- src/offset.js | 28 ++++++++++++++-------------- test/unit/offset.js | 8 +++++++- 2 files changed, 21 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/offset.js b/src/offset.js index 2040c9d83..d53a8813b 100644 --- a/src/offset.js +++ b/src/offset.js @@ -261,13 +261,9 @@ jQuery.each( ["Left", "Top"], function( i, name ) { var method = "scroll" + name; jQuery.fn[ method ] = function(val) { - var elem = this[0], win; + var elem, win; - if ( !elem ) { - return null; - } - - if ( val !== undefined ) { + if ( val != undefined ) { // Set the scroll offset return this.each(function() { win = getWindow( this ); @@ -282,15 +278,19 @@ jQuery.each( ["Left", "Top"], function( i, name ) { this[ method ] = val; } }); - } else { - win = getWindow( elem ); - - // Return the scroll offset - return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] : - jQuery.support.boxModel && win.document.documentElement[ method ] || - win.document.body[ method ] : - elem[ method ]; } + + elem = this[0]; + if( !elem ) { + return null + } + + win = getWindow( elem ); + // Return the scroll offset + return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] : + jQuery.support.boxModel && win.document.documentElement[ method ] || + win.document.body[ method ] : + elem[ method ]; }; }); diff --git a/test/unit/offset.js b/test/unit/offset.js index cfa14449b..66676def5 100644 --- a/test/unit/offset.js +++ b/test/unit/offset.js @@ -333,7 +333,7 @@ testoffset("table", function( jQuery ) { }); testoffset("scroll", function( jQuery, win ) { - expect(16); + expect(20); var ie = jQuery.browser.msie && parseInt( jQuery.browser.version, 10 ) < 8; @@ -379,6 +379,12 @@ testoffset("scroll", function( jQuery, win ) { equals( jQuery(window).scrollLeft(), 0, "jQuery(window).scrollLeft() other window" ); equals( jQuery(document).scrollTop(), 0, "jQuery(window).scrollTop() other document" ); equals( jQuery(document).scrollLeft(), 0, "jQuery(window).scrollLeft() other document" ); + + // Tests scrollTop/Left with empty jquery objects + ok( jQuery().scrollTop(100) != null, "jQuery().scrollTop(100) testing setter on empty jquery object" ); + ok( jQuery().scrollLeft(100) != null, "jQuery().scrollLeft(100) testing setter on empty jquery object" ); + ok( jQuery().scrollTop() === null, "jQuery().scrollTop(100) testing setter on empty jquery object" ); + ok( jQuery().scrollLeft() === null, "jQuery().scrollLeft(100) testing setter on empty jquery object" ); }); testoffset("body", function( jQuery ) { -- cgit v1.2.3 From 628bacc3ce26a7a0e0462c2a2e0d764edf859c97 Mon Sep 17 00:00:00 2001 From: Xavi Date: Sun, 9 Jan 2011 20:12:29 -0500 Subject: Bug 7931; Added missing semicolon and replaced '!=' with '!==' to allow null through --- src/offset.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/offset.js b/src/offset.js index d53a8813b..02f067ebb 100644 --- a/src/offset.js +++ b/src/offset.js @@ -263,7 +263,7 @@ jQuery.each( ["Left", "Top"], function( i, name ) { jQuery.fn[ method ] = function(val) { var elem, win; - if ( val != undefined ) { + if ( val !== undefined ) { // Set the scroll offset return this.each(function() { win = getWindow( this ); @@ -282,7 +282,7 @@ jQuery.each( ["Left", "Top"], function( i, name ) { elem = this[0]; if( !elem ) { - return null + return null; } win = getWindow( elem ); -- cgit v1.2.3 From b78e3fc39f96d63a60ea66e3d066815626e633d8 Mon Sep 17 00:00:00 2001 From: Xavi Date: Sun, 9 Jan 2011 20:51:20 -0500 Subject: Bug 7931; Inverted logic in scrollTop/Left (i.e. made --- src/offset.js | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/offset.js b/src/offset.js index 02f067ebb..660efa234 100644 --- a/src/offset.js +++ b/src/offset.js @@ -263,34 +263,34 @@ jQuery.each( ["Left", "Top"], function( i, name ) { jQuery.fn[ method ] = function(val) { var elem, win; - if ( val !== undefined ) { - // Set the scroll offset - return this.each(function() { - win = getWindow( this ); - - if ( win ) { - win.scrollTo( - !i ? val : jQuery(win).scrollLeft(), - i ? val : jQuery(win).scrollTop() - ); - - } else { - this[ method ] = val; - } - }); - } + if(val === undefined) { + elem = this[0]; + if( !elem ) { + return null; + } - elem = this[0]; - if( !elem ) { - return null; + win = getWindow( elem ); + // Return the scroll offset + return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] : + jQuery.support.boxModel && win.document.documentElement[ method ] || + win.document.body[ method ] : + elem[ method ]; } - win = getWindow( elem ); - // Return the scroll offset - return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] : - jQuery.support.boxModel && win.document.documentElement[ method ] || - win.document.body[ method ] : - elem[ method ]; + // Set the scroll offset + return this.each(function() { + win = getWindow( this ); + + if ( win ) { + win.scrollTo( + !i ? val : jQuery(win).scrollLeft(), + i ? val : jQuery(win).scrollTop() + ); + + } else { + this[ method ] = val; + } + }); }; }); -- cgit v1.2.3 From 75655e5758bc786989f26a98b09aabbfb88f66fd Mon Sep 17 00:00:00 2001 From: Sylvester Keil Date: Sat, 15 Jan 2011 13:56:20 +0100 Subject: Use parseFloat instead of parseInt to read CSS values. This fixes #7730 and #7885. --- src/offset.js | 8 +++++--- test/unit/offset.js | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/offset.js b/src/offset.js index 2040c9d83..94b67c77a 100644 --- a/src/offset.js +++ b/src/offset.js @@ -187,11 +187,13 @@ jQuery.offset = { // need to be able to calculate position if either top or left is auto and position is absolute if ( calculatePosition ) { curPosition = curElem.position(); + curTop = curPosition.top; + curLeft = curPosition.left; + } else { + curTop = parseFloat( curCSSTop ) || 0; + curLeft = parseFloat( curCSSLeft ) || 0; } - curTop = calculatePosition ? curPosition.top : parseInt( curCSSTop, 10 ) || 0; - curLeft = calculatePosition ? curPosition.left : parseInt( curCSSLeft, 10 ) || 0; - if ( jQuery.isFunction( options ) ) { options = options.call( elem, i, curOffset ); } diff --git a/test/unit/offset.js b/test/unit/offset.js index cfa14449b..1f8c3b15c 100644 --- a/test/unit/offset.js +++ b/test/unit/offset.js @@ -422,6 +422,32 @@ test("offsetParent", function(){ equals( div[1], jQuery("#nothiddendiv")[0], "The div is the offsetParent." ); }); +test("fractions (see #7730 and #7885)", function() { + expect(2); + + jQuery('body').append('
'); + + var expected = { top: 1000, left: 1000 }; + var div = jQuery('#fractions'); + + div.css({ + position: 'absolute', + left: '1000.7432222px', + top: '1000.532325px', + width: 100, + height: 100 + }); + + div.offset(expected); + + var result = div.offset(); + + equals( result.top, expected.top, "Check top" ); + equals( result.left, expected.left, "Check left" ); + + div.remove(); +}); + function testoffset(name, fn) { test(name, function() { -- cgit v1.2.3 From 135a384cf3e4cc3671de4cfcced20f294a5667a8 Mon Sep 17 00:00:00 2001 From: Xavi Date: Tue, 18 Jan 2011 12:40:07 -0500 Subject: Bug 7931; cleaned up white space in accordance to style guide --- src/offset.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/offset.js b/src/offset.js index 660efa234..8696c2051 100644 --- a/src/offset.js +++ b/src/offset.js @@ -260,15 +260,15 @@ jQuery.fn.extend({ jQuery.each( ["Left", "Top"], function( i, name ) { var method = "scroll" + name; - jQuery.fn[ method ] = function(val) { + jQuery.fn[ method ] = function( val ) { var elem, win; - if(val === undefined) { - elem = this[0]; + if( val === undefined ) { + elem = this[ 0 ]; if( !elem ) { return null; } - + win = getWindow( elem ); // Return the scroll offset return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] : @@ -276,17 +276,16 @@ jQuery.each( ["Left", "Top"], function( i, name ) { win.document.body[ method ] : elem[ method ]; } - + // Set the scroll offset return this.each(function() { win = getWindow( this ); if ( win ) { win.scrollTo( - !i ? val : jQuery(win).scrollLeft(), - i ? val : jQuery(win).scrollTop() + !i ? val : jQuery( win ).scrollLeft(), + i ? val : jQuery( win ).scrollTop() ); - } else { this[ method ] = val; } -- cgit v1.2.3 From 82626799cacef94a1b35d0a0b4d284b38104704b Mon Sep 17 00:00:00 2001 From: Timmy Willison Date: Sun, 6 Feb 2011 19:34:57 -0500 Subject: Changed $.sub internals to match sub naming, added some more spacing in some areas for readability --- src/core.js | 36 ++++++++++++++++++------------------ src/css.js | 14 +++++++------- src/event.js | 6 ++---- 3 files changed, 27 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/core.js b/src/core.js index 2e6347236..1bc4c1cfb 100644 --- a/src/core.js +++ b/src/core.js @@ -441,7 +441,7 @@ jQuery.extend({ } else if ( document.attachEvent ) { // ensure firing before onload, // maybe late but safe also for iframes - document.attachEvent("onreadystatechange", DOMContentLoaded); + document.attachEvent( "onreadystatechange", DOMContentLoaded ); // A fallback to window.onload, that will always work window.attachEvent( "onload", jQuery.ready ); @@ -598,7 +598,7 @@ jQuery.extend({ each: function( object, callback, args ) { var name, i = 0, length = object.length, - isObj = length === undefined || jQuery.isFunction(object); + isObj = length === undefined || jQuery.isFunction( object ); if ( args ) { if ( isObj ) { @@ -625,7 +625,7 @@ jQuery.extend({ } } else { for ( var value = object[0]; - i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {} + i < length && callback.call( value, i, value ) !== false; value = object[ ++i ] ) {} } } @@ -656,7 +656,7 @@ jQuery.extend({ // The extra typeof function check is to prevent crashes // in Safari 2 (See: #3039) // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930 - var type = jQuery.type(array); + var type = jQuery.type( array ); if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) { push.call( ret, array ); @@ -982,24 +982,24 @@ jQuery.extend({ }, sub: function() { - function jQuerySubclass( selector, context ) { - return new jQuerySubclass.fn.init( selector, context ); + function jQuerySub( selector, context ) { + return new jQuerySub.fn.init( selector, context ); } - jQuery.extend( true, jQuerySubclass, this ); - jQuerySubclass.superclass = this; - jQuerySubclass.fn = jQuerySubclass.prototype = this(); - jQuerySubclass.fn.constructor = jQuerySubclass; - jQuerySubclass.subclass = this.subclass; - jQuerySubclass.fn.init = function init( selector, context ) { - if ( context && context instanceof jQuery && !(context instanceof jQuerySubclass) ) { - context = jQuerySubclass(context); + jQuery.extend( true, jQuerySub, this ); + jQuerySub.superclass = this; + jQuerySub.fn = jQuerySub.prototype = this(); + jQuerySub.fn.constructor = jQuerySub; + jQuerySub.sub = this.sub; + jQuerySub.fn.init = function init( selector, context ) { + if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) { + context = jQuerySub( context ); } - return jQuery.fn.init.call( this, selector, context, rootjQuerySubclass ); + return jQuery.fn.init.call( this, selector, context, rootjQuerySub ); }; - jQuerySubclass.fn.init.prototype = jQuerySubclass.fn; - var rootjQuerySubclass = jQuerySubclass(document); - return jQuerySubclass; + jQuerySub.fn.init.prototype = jQuerySub.fn; + var rootjQuerySub = jQuerySub(document); + return jQuerySub; }, browser: {} diff --git a/src/css.js b/src/css.js index 19c6342d2..968188d6e 100644 --- a/src/css.js +++ b/src/css.js @@ -215,8 +215,8 @@ if ( !jQuery.support.opacity ) { jQuery.cssHooks.opacity = { get: function( elem, computed ) { // IE uses filters for opacity - return ropacity.test((computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "") ? - (parseFloat(RegExp.$1) / 100) + "" : + return ropacity.test( (computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "" ) ? + ( parseFloat( RegExp.$1 ) / 100 ) + "" : computed ? "1" : ""; }, @@ -228,13 +228,13 @@ if ( !jQuery.support.opacity ) { style.zoom = 1; // Set the alpha filter to set the opacity - var opacity = jQuery.isNaN(value) ? - "" : - "alpha(opacity=" + value * 100 + ")", + var opacity = jQuery.isNaN( value ) ? + "" : + "alpha(opacity=" + value * 100 + ")", filter = style.filter || ""; - style.filter = ralpha.test(filter) ? - filter.replace(ralpha, opacity) : + style.filter = ralpha.test( filter ) ? + filter.replace( ralpha, opacity ) : style.filter + ' ' + opacity; } }; diff --git a/src/event.js b/src/event.js index 2d53562ad..01b05149a 100644 --- a/src/event.js +++ b/src/event.js @@ -294,11 +294,9 @@ jQuery.event = { } }, - // bubbling is internal - trigger: function( event, data, elem /*, bubbling */ ) { + trigger: function( event, data, elem, bubbling /* For Internal Use Only */ ) { // Event object or event type - var type = event.type || event, - bubbling = arguments[3]; + var type = event.type || event; if ( !bubbling ) { event = typeof event === "object" ? -- cgit v1.2.3 From 025f2c63e487e069215b2a03ded2b98198904af9 Mon Sep 17 00:00:00 2001 From: louisremi Date: Tue, 1 Mar 2011 00:54:15 +0100 Subject: fixing both #8403 and #8401: jQuery \"bulldozes\" other IE filters when setting opacity --- src/css.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/css.js b/src/css.js index 8a982312f..9fdba3b7b 100644 --- a/src/css.js +++ b/src/css.js @@ -221,7 +221,8 @@ if ( !jQuery.support.opacity ) { }, set: function( elem, value ) { - var style = elem.style; + var style = elem.style, + currentStyle = elem.currentStyle; // IE has trouble with opacity if it does not have layout // Force it by setting the zoom level @@ -231,11 +232,11 @@ if ( !jQuery.support.opacity ) { var opacity = jQuery.isNaN(value) ? "" : "alpha(opacity=" + value * 100 + ")", - filter = style.filter || ""; + filter = currentStyle && currentStyle.filter || style.filter || ""; style.filter = ralpha.test(filter) ? filter.replace(ralpha, opacity) : - style.filter + ' ' + opacity; + filter + ' ' + opacity; } }; } -- cgit v1.2.3 From 3296116041ea0eb89e123c24cf092e34ccb3f380 Mon Sep 17 00:00:00 2001 From: Jordan Boesch Date: Wed, 30 Mar 2011 11:17:48 -0600 Subject: Bug 4366; fixing $.each(document.styleSheets) from throwing errors in IE --- src/core.js | 7 +++++-- test/unit/core.js | 9 ++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/core.js b/src/core.js index 9312ee288..1b06913c3 100644 --- a/src/core.js +++ b/src/core.js @@ -610,8 +610,11 @@ jQuery.extend({ } } } else { - for ( var value = object[0]; - i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {} + for ( ; i < length; ) { + if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) { + break; + } + } } } diff --git a/test/unit/core.js b/test/unit/core.js index 6ee8724de..39b7d275c 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -784,7 +784,7 @@ test("jQuery.extend(Object, Object)", function() { }); test("jQuery.each(Object,Function)", function() { - expect(13); + expect(14); jQuery.each( [0,1,2], function(i, n){ equals( i, n, "Check array iteration" ); }); @@ -816,6 +816,13 @@ test("jQuery.each(Object,Function)", function() { f[i] = 'baz'; }); equals( "baz", f.foo, "Loop over a function" ); + + var stylesheet_count = 0; + jQuery.each(document.styleSheets, function(i){ + stylesheet_count++; + }); + equals(stylesheet_count, 2, "should not throw an error in IE while looping over document.styleSheets and return proper amount"); + }); test("jQuery.makeArray", function(){ -- cgit v1.2.3 From 926884bf1f071b6dd92f0611d905b2cbffa16a19 Mon Sep 17 00:00:00 2001 From: Jordan Boesch Date: Wed, 30 Mar 2011 11:26:20 -0600 Subject: Bug 4366; removing extra space --- src/core.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/core.js b/src/core.js index 1b06913c3..7cf99372e 100644 --- a/src/core.js +++ b/src/core.js @@ -611,7 +611,7 @@ jQuery.extend({ } } else { for ( ; i < length; ) { - if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) { + if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) { break; } } -- cgit v1.2.3 From 4b0c26f0af96da05ab1a0166268c2925a6e6e6ac Mon Sep 17 00:00:00 2001 From: rwldrn Date: Tue, 5 Apr 2011 18:12:50 -0400 Subject: Ticket #8777 undelegate by namespace --- src/event.js | 13 +++++++++++-- test/unit/event.js | 34 ++++++++++++++++++++++++++++------ 2 files changed, 39 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/event.js b/src/event.js index bc2cf76eb..6fac59c74 100644 --- a/src/event.js +++ b/src/event.js @@ -868,10 +868,10 @@ function trigger( type, elem, args ) { // Create "bubbling" focus and blur events if ( document.addEventListener ) { jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { - + // Attach a single capturing handler while someone wants focusin/focusout var attaches = 0; - + jQuery.event.special[ fix ] = { setup: function() { if ( attaches++ === 0 ) { @@ -1027,6 +1027,14 @@ jQuery.each(["live", "die"], function( i, name ) { return this; } + if ( name === "die" && !types && + origSelector && origSelector[0] === "." ) { + + context.unbind( origSelector ); + + return this; + } + if ( jQuery.isFunction( data ) ) { fn = data; data = undefined; @@ -1184,3 +1192,4 @@ jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblcl }); })( jQuery ); + diff --git a/test/unit/event.js b/test/unit/event.js index 2a6d8a669..cc6901ff6 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -685,7 +685,7 @@ test("hover()", function() { test("mouseover triggers mouseenter", function() { expect(1); - + var count = 0, elem = jQuery(""); elem.mouseenter(function () { @@ -693,7 +693,7 @@ test("mouseover triggers mouseenter", function() { }); elem.trigger('mouseover'); equals(count, 1, "make sure mouseover triggers a mouseenter" ); - + elem.remove(); }); @@ -1956,6 +1956,27 @@ test("delegate with submit", function() { jQuery(document).undelegate(); }); +test("undelegate() with only namespaces", function(){ + expect(2); + + var $delegate = jQuery("#liveHandlerOrder"), + count = 0; + + $delegate.delegate("a", "click.ns", function(e) { + count++; + }); + + jQuery("a", $delegate).eq(0).trigger("click.ns"); + + equals( count, 1, "delegated click.ns"); + + $delegate.undelegate(".ns"); + + jQuery("a", $delegate).eq(1).trigger("click.ns"); + + equals( count, 1, "no more .ns after undelegate"); +}); + test("Non DOM element events", function() { expect(1); @@ -1982,8 +2003,8 @@ test("window resize", function() { test("focusin bubbles", function() { expect(5); - - var input = jQuery( '' ).prependTo( "body" ), + + var input = jQuery( '' ).prependTo( "body" ), order = 0; jQuery( "body" ).bind( "focusin.focusinBubblesTest", function(){ @@ -1996,12 +2017,12 @@ test("focusin bubbles", function() { // DOM focus method input[0].focus(); - + // To make the next focus test work, we need to take focus off the input. // This will fire another focusin event, so set order to reflect that. order = 1; jQuery("#text1")[0].focus(); - + // jQuery trigger, which calls DOM focus order = 0; input.trigger( "focus" ); @@ -2027,3 +2048,4 @@ test("event properties", function() { }).click(); }); */ + -- cgit v1.2.3 From 2f11ba7c98d4d2d2157b7ae554f57f1798b04306 Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Wed, 6 Apr 2011 23:41:47 -0400 Subject: Allow specific custom events to exit trigger early if there are no handlers bound for that type. --- src/event.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/event.js b/src/event.js index 9a63b5f93..d39bf7ac0 100644 --- a/src/event.js +++ b/src/event.js @@ -276,6 +276,14 @@ jQuery.event = { } } }, + + // Events that are safe to short-circuit if no handlers are attached. + // Native DOM events should not be added, they may have inline handlers. + customEvent: { + "getData": true, + "setData": true, + "changeData": true + }, trigger: function( event, data, elem ) { // Event object or event type @@ -293,7 +301,7 @@ jQuery.event = { jQuery.Event(type); if ( type.indexOf("!") >= 0 ) { - // Exclusive events trigger only for the bare event type (no namespaces) + // Exclusive events trigger only for the bare event type (no namespaces) event.type = type = type.slice(0, -1); event.exclusive = true; } @@ -305,7 +313,12 @@ jQuery.event = { } event.namespace = namespaces.join("."); event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)"); - + + if ( jQuery.event.customEvent[ type ] && !jQuery.event.global[ type ] ) { + // No jQuery handlers for this event type, and it can't have inline handlers + return; + } + // Handle a global trigger if ( !elem ) { // Don't bubble custom events when global (to avoid too much overhead) -- cgit v1.2.3 From 3411d47a6a952e283864d2401438a6764d925b74 Mon Sep 17 00:00:00 2001 From: jaubourg Date: Mon, 11 Apr 2011 13:40:14 +0200 Subject: Adds _mark and _unmark as a mean to keep track of ongoing non-queued animations in fn.promise. --- src/effects.js | 17 ++++++-- src/queue.js | 92 ++++++++++++++++++++++++++++++-------------- test/unit/queue.js | 111 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 183 insertions(+), 37 deletions(-) (limited to 'src') diff --git a/src/effects.js b/src/effects.js index ad2ed3c97..d6eff7b32 100644 --- a/src/effects.js +++ b/src/effects.js @@ -118,13 +118,17 @@ jQuery.fn.extend({ var optall = jQuery.speed(speed, easing, callback); if ( jQuery.isEmptyObject( prop ) ) { - return this.each( optall.complete ); + return this.each( optall.complete, [ false ] ); } return this[ optall.queue === false ? "each" : "queue" ](function() { // XXX 'this' does not always have a nodeName when running the // test suite + if ( optall.queue === false ) { + jQuery._mark( this ); + } + var opt = jQuery.extend({}, optall), p, isElement = this.nodeType === 1, hidden = isElement && jQuery(this).is(":hidden"), @@ -234,6 +238,10 @@ jQuery.fn.extend({ } this.each(function() { + // clear marker counters if we know they won't be + if ( !gotoEnd ) { + jQuery._unmark( true, this ); + } // go in reverse order so anything added to the queue during the loop is ignored for ( var i = timers.length - 1; i >= 0; i-- ) { if ( timers[i].elem === this ) { @@ -295,10 +303,13 @@ jQuery.extend({ // Queueing opt.old = opt.complete; - opt.complete = function() { + opt.complete = function( noUnmark ) { if ( opt.queue !== false ) { - jQuery(this).dequeue(); + jQuery.dequeue( this ); + } else if ( noUnmark !== false ) { + jQuery._unmark( this ); } + if ( jQuery.isFunction( opt.old ) ) { opt.old.call( this ); } diff --git a/src/queue.js b/src/queue.js index 701d06ade..ab06ae924 100644 --- a/src/queue.js +++ b/src/queue.js @@ -1,32 +1,74 @@ (function( jQuery ) { +function handleQueueMarkDefer( elem, type, src ) { + var deferDataKey = type + "defer", + queueDataKey = type + "queue", + markDataKey = type + "mark", + defer = jQuery.data( elem, deferDataKey, undefined, true ); + if ( defer && + ( src === "queue" || !jQuery.data( elem, queueDataKey, undefined, true ) ) && + ( src === "mark " || !jQuery.data( elem, markDataKey, undefined, true ) ) ) { + // Give room for hard-coded callbacks to fire first + // and eventually mark/queue something else on the element + setTimeout( function() { + if ( !jQuery.data( elem, queueDataKey, undefined, true ) && + !jQuery.data( elem, markDataKey, undefined, true ) ) { + jQuery.removeData( elem, deferDataKey, true ); + defer.resolve(); + } + }, 0 ); + } +} + jQuery.extend({ - queue: function( elem, type, data ) { - if ( !elem ) { - return; - } - type = (type || "fx") + "queue"; - var q = jQuery._data( elem, type ); + _mark: function( elem, type ) { + if ( elem ) { + type = (type || "fx") + "mark"; + jQuery.data( elem, type, (jQuery.data(elem,type,undefined,true) || 0) + 1, true ); + } + }, - // Speed up dequeue by getting out quickly if this is just a lookup - if ( !data ) { - return q || []; + _unmark: function( force, elem, type ) { + if ( force !== true ) { + type = elem; + elem = force; + force = false; } - if ( !q || jQuery.isArray(data) ) { - q = jQuery._data( elem, type, jQuery.makeArray(data) ); + if ( elem ) { + type = type || "fx"; + + var key = type + "mark", + count = force ? 0 : ( (jQuery.data( elem, key, undefined, true) || 1 ) - 1 ); - } else { - q.push( data ); + if ( count ) { + jQuery.data( elem, key, count, true ); + } else { + jQuery.removeData( elem, key, true ); + handleQueueMarkDefer( elem, type, "mark" ); + } } + }, - return q; + queue: function( elem, type, data ) { + if ( elem ) { + type = (type || "fx") + "queue"; + var q = jQuery.data( elem, type, undefined, true ) || []; + + // Speed up dequeue by getting out quickly if this is just a lookup + if ( data ) { + if ( !q.length || jQuery.isArray(data) ) { + q = jQuery.data( elem, type, jQuery.makeArray(data), true ); + } else { + q.push( data ); + } + } + return q; + } }, dequeue: function( elem, type ) { - type = type || "fx"; - var queue = jQuery.queue( elem, type ), fn = queue.shift(), defer; @@ -50,17 +92,7 @@ jQuery.extend({ if ( !queue.length ) { jQuery.removeData( elem, type + "queue", true ); - // Look if we have observers and resolve if needed - if (( defer = jQuery.data( elem, type + "defer", undefined, true ) )) { - // Give room for hard-coded callbacks to fire first - // and eventually add another animation on the element - setTimeout( function() { - if ( !jQuery.data( elem, type + "queue", undefined, true ) ) { - jQuery.removeData( elem, type + "defer", true ); - defer.resolve(); - } - }, 0 ); - } + handleQueueMarkDefer( elem, type, "queue" ); } } }); @@ -120,7 +152,8 @@ jQuery.fn.extend({ i = elements.length, count = 1, deferDataKey = type + "defer", - queueDataKey = type + "queue"; + queueDataKey = type + "queue", + markDataKey = type + "mark"; function resolve() { if ( !( --count ) ) { defer.resolveWith( elements, [ elements ] ); @@ -128,7 +161,8 @@ jQuery.fn.extend({ } while( i-- ) { if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) || - jQuery.data( elements[ i ], queueDataKey, undefined, true ) && + ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) || + jQuery.data( elements[ i ], markDataKey, undefined, true ) ) && jQuery.data( elements[ i ], deferDataKey, jQuery._Deferred(), true ) )) { count++; tmp.done( resolve ); diff --git a/test/unit/queue.js b/test/unit/queue.js index 31e587db2..05461cd26 100644 --- a/test/unit/queue.js +++ b/test/unit/queue.js @@ -1,10 +1,17 @@ module("queue", { teardown: moduleTeardown }); test("queue() with other types",function() { - expect(9); + expect(11); var counter = 0; - var $div = jQuery({}); + stop(); + + var $div = jQuery({}), + defer; + + $div.promise('foo').done(function() { + equals( counter, 0, "Deferred for collection with no queue is automatically resolved" ); + }); $div .queue('foo',function(){ @@ -22,6 +29,11 @@ test("queue() with other types",function() { equals( ++counter, 4, "Dequeuing" ); }); + defer = $div.promise('foo').done(function() { + equals( counter, 4, "Testing previous call to dequeue in deferred" ); + start(); + }); + equals( $div.queue('foo').length, 4, "Testing queue length" ); $div.dequeue('foo'); @@ -74,7 +86,7 @@ test("queue(name) passes in the next item in the queue as a parameter", function }); test("queue() passes in the next item in the queue as a parameter to fx queues", function() { - expect(2); + expect(3); stop(); var div = jQuery({}); @@ -87,11 +99,15 @@ test("queue() passes in the next item in the queue as a parameter to fx queues", }).queue(function(next) { equals(++counter, 2, "Next was called"); next(); - start(); }).queue("bar", function() { equals(++counter, 3, "Other queues are not triggered by next()") }); + jQuery.when( div.promise("fx"), div ).done(function() { + equals(counter, 2, "Deferreds resolved"); + start(); + }); + }); test("delay()", function() { @@ -110,7 +126,9 @@ test("delay()", function() { }); test("clearQueue(name) clears the queue", function() { - expect(1); + expect(2); + + stop() var div = jQuery({}); var counter = 0; @@ -123,6 +141,11 @@ test("clearQueue(name) clears the queue", function() { counter++; }); + div.promise("foo").done(function() { + ok( true, "dequeue resolves the deferred" ); + start(); + }); + div.dequeue("foo"); equals(counter, 1, "the queue was cleared"); @@ -146,3 +169,81 @@ test("clearQueue() clears the fx queue", function() { div.removeData(); }); + +test("_mark() and _unmark()", function() { + expect(1); + + var div = {}, + $div = jQuery( div ); + + stop(); + + jQuery._mark( div, "foo" ); + jQuery._mark( div, "foo" ); + jQuery._unmark( div, "foo" ); + jQuery._unmark( div, "foo" ); + + $div.promise( "foo" ).done(function() { + ok( true, "No more marks" ); + start(); + }); +}); + +test("_mark() and _unmark() default to 'fx'", function() { + expect(1); + + var div = {}, + $div = jQuery( div ); + + stop(); + + jQuery._mark( div ); + jQuery._mark( div ); + jQuery._unmark( div, "fx" ); + jQuery._unmark( div ); + + $div.promise().done(function() { + ok( true, "No more marks" ); + start(); + }); +}); + +test("promise()", function() { + expect(1); + + stop(); + + var objects = []; + + jQuery.each( [{}, {}], function( i, div ) { + var $div = jQuery( div ); + $div.queue(function( next ) { + setTimeout( function() { + if ( i ) { + next(); + setTimeout( function() { + jQuery._unmark( div ); + }, 20 ); + } else { + jQuery._unmark( div ); + setTimeout( function() { + next(); + }, 20 ); + } + }, 50 ); + }).queue(function( next ) { + next(); + }); + jQuery._mark( div ); + objects.push( $div ); + }); + + jQuery.when.apply( jQuery, objects ).done(function() { + ok( true, "Deferred resolved" ); + start(); + }); + + jQuery.each( objects, function() { + this.dequeue(); + }); +}); -- cgit v1.2.3 From 530c915553dd21f7f933d6d1ca8102ae714f5aa2 Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Mon, 11 Apr 2011 11:15:00 -0400 Subject: Move initialization of event until we determine if anyone wants it. --- src/event.js | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/event.js b/src/event.js index 3d19e50c2..95f305bab 100644 --- a/src/event.js +++ b/src/event.js @@ -289,35 +289,38 @@ jQuery.event = { trigger: function( event, data, elem ) { // Event object or event type var type = event.type || event, - namespaces = []; - - event = typeof event === "object" ? - // jQuery.Event object - event[ jQuery.expando ] ? event : - // Object literal - jQuery.extend( jQuery.Event(type), event ) : - // Just the event type (string) - jQuery.Event(type); + namespaces = [], + exclusive; if ( type.indexOf("!") >= 0 ) { - // Exclusive events trigger only for the bare event type (no namespaces) - event.type = type = type.slice(0, -1); - event.exclusive = true; + // Exclusive events trigger only for the exact event (no namespaces) + type = type.slice(0, -1); + exclusive = true; } if ( type.indexOf(".") >= 0 ) { // Namespaced trigger; create a regexp to match event type in handle() namespaces = type.split("."); - event.type = type = namespaces.shift(); + type = namespaces.shift(); namespaces.sort(); } - event.namespace = namespaces.join("."); - event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)"); if ( jQuery.event.customEvent[ type ] && !jQuery.event.global[ type ] ) { // No jQuery handlers for this event type, and it can't have inline handlers return; } + // Caller can pass in an Event, Object, or just an event type string + event = typeof event === "object" ? + // jQuery.Event object + event[ jQuery.expando ] ? event : + // Object literal + jQuery.extend( jQuery.Event(type), event ) : + // Just the event type (string) + jQuery.Event(type); + event.namespace = namespaces.join("."); + event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)"); + event.exclusive = exclusive; + // Handle a global trigger if ( !elem ) { // Don't bubble custom events when global (to avoid too much overhead) -- cgit v1.2.3 From 868e1e28ce7cee543e0e47ec2261b44c4c686f99 Mon Sep 17 00:00:00 2001 From: Rick Waldon Date: Mon, 11 Apr 2011 11:32:23 -0400 Subject: Ticket #8753 Always set event type explicitly --- src/event.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/event.js b/src/event.js index ac0da6b7e..249e81ff6 100644 --- a/src/event.js +++ b/src/event.js @@ -304,7 +304,7 @@ jQuery.event = { } event.namespace = namespaces.join("."); event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)"); - + // Handle a global trigger if ( !elem ) { // Don't bubble custom events when global (to avoid too much overhead) @@ -574,6 +574,9 @@ jQuery.Event = function( src ) { } } + // Always ensure a type has been explicitly set + this.type = src.type; + // Events bubbling up the document may have been marked as prevented // by a handler lower down the tree; reflect the correct value. this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false || @@ -1033,7 +1036,7 @@ jQuery.each(["live", "die"], function( i, name ) { if ( data === false || jQuery.isFunction( data ) ) { fn = data || returnFalse; data = undefined; - } + } types = (types || "").split(" "); -- cgit v1.2.3 From eb857e2b714e6786078cf8641941f267a6e19fa0 Mon Sep 17 00:00:00 2001 From: timmywil Date: Mon, 11 Apr 2011 11:54:55 -0400 Subject: Fix unit tests in firefox 4 and opera 11, passing null or undefined to indexOf was throwing an error in those browsers --- src/traversing.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/traversing.js b/src/traversing.js index fb5946bba..485de56d4 100644 --- a/src/traversing.js +++ b/src/traversing.js @@ -298,13 +298,18 @@ jQuery.extend({ // Implement the identical functionality for filter and not function winnow( elements, qualifier, keep ) { + + // Can't pass null or undefined to indexOf in Firefox 4 + // Set to 0 to skip string check + qualifier = qualifier || 0; + if ( jQuery.isFunction( qualifier ) ) { return jQuery.grep(elements, function( elem, i ) { var retVal = !!qualifier.call( elem, i, elem ); return retVal === keep; }); - } else if ( qualifier && qualifier.nodeType ) { + } else if ( qualifier.nodeType ) { return jQuery.grep(elements, function( elem, i ) { return (elem === qualifier) === keep; }); -- cgit v1.2.3 From a564a0b1ec167b2f0fdd2d017a986b226a9850f6 Mon Sep 17 00:00:00 2001 From: timmywil Date: Mon, 11 Apr 2011 12:24:31 -0400 Subject: Run order problem when running full test suite in Opera 11, removed failing test as it passed by itself and there are others just like it --- src/traversing.js | 4 ++-- test/unit/traversing.js | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/traversing.js b/src/traversing.js index 485de56d4..e0f40151d 100644 --- a/src/traversing.js +++ b/src/traversing.js @@ -73,9 +73,9 @@ jQuery.fn.extend({ }, is: function( selector ) { - return !!selector && (typeof selector === "string" ? + return !!selector && ( typeof selector === "string" ? jQuery.filter( selector, this ).length > 0 : - this.filter( selector ).length > 0); + this.filter( selector ).length > 0 ); }, closest: function( selectors, context ) { diff --git a/test/unit/traversing.js b/test/unit/traversing.js index f622082e7..140b337aa 100644 --- a/test/unit/traversing.js +++ b/test/unit/traversing.js @@ -72,7 +72,7 @@ test("is(String|undefined)", function() { }); test("is(jQuery)", function() { - expect(24); + expect(23); ok( jQuery('#form').is( jQuery('form') ), 'Check for element: A form is a form' ); ok( !jQuery('#form').is( jQuery('div') ), 'Check for element: A form is not a div' ); ok( jQuery('#mark').is( jQuery('.blog') ), 'Check for class: Expected class "blog"' ); @@ -83,7 +83,6 @@ test("is(jQuery)", function() { ok( !jQuery('#en').is( jQuery('[lang="de"]') ), 'Check for attribute: Expected attribute lang to be "en", not "de"' ); ok( jQuery('#text1').is( jQuery('[type="text"]') ), 'Check for attribute: Expected attribute type to be "text"' ); ok( !jQuery('#text1').is( jQuery('[type="radio"]') ), 'Check for attribute: Expected attribute type to be "text", not "radio"' ); - ok( jQuery('#text2').is( jQuery(':disabled') ), 'Check for pseudoclass: Expected to be disabled' ); ok( !jQuery('#text1').is( jQuery(':disabled') ), 'Check for pseudoclass: Expected not disabled' ); ok( jQuery('#radio2').is( jQuery(':checked') ), 'Check for pseudoclass: Expected to be checked' ); ok( !jQuery('#radio1').is( jQuery(':checked') ), 'Check for pseudoclass: Expected not checked' ); -- cgit v1.2.3 From a5071d49ba29ba115954845db9363aa6459f1a84 Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Mon, 11 Apr 2011 13:19:00 -0400 Subject: Shave some time off array setup in trigger/handle --- src/event.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/event.js b/src/event.js index e6e7788da..097bc6501 100644 --- a/src/event.js +++ b/src/event.js @@ -354,7 +354,7 @@ jQuery.event = { event.target = elem; // Clone any incoming data and prepend the event, creating the handler arg list - data = jQuery.makeArray( data ); + data = data? jQuery.makeArray( data ) : []; data.unshift( event ); var cur = elem, @@ -419,7 +419,7 @@ jQuery.event = { // Snapshot the handlers list since a called handler may add/remove events. var handlers = ((jQuery._data( this, "events" ) || {})[ event.type ] || []).slice(0), run_all = !event.exclusive && !event.namespace, - args = jQuery.makeArray( arguments ); + args = Array.prototype.slice.call( arguments, 0 ); // Use the fix-ed Event rather than the (read-only) native event args[0] = event; -- cgit v1.2.3 From 272b8d69dcff771ffdb61ccd33c4e83eaea8ca50 Mon Sep 17 00:00:00 2001 From: louisremi Date: Mon, 11 Apr 2011 20:33:52 +0200 Subject: replace cssPropsAware branch --- src/css.js | 18 ++++++++++++------ test/unit/css.js | 14 ++++++++++++++ 2 files changed, 26 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/css.js b/src/css.js index 65ec20f57..d53a1f63c 100644 --- a/src/css.js +++ b/src/css.js @@ -123,10 +123,16 @@ jQuery.extend({ css: function( elem, name, extra ) { // Make sure that we're working with the right name - var ret, origName = jQuery.camelCase( name ), - hooks = jQuery.cssHooks[ origName ]; - - name = jQuery.cssProps[ origName ] || origName; + var ret, + hooks; + + name = jQuery.camelCase( name ); + hooks = jQuery.cssHooks[ name ]; + name = jQuery.cssProps[ name ] || name; + // cssFloat needs a special treatment + if ( name === 'cssFloat' ) { + name = 'float'; + } // If a hook was provided get the computed value from there if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) { @@ -134,7 +140,7 @@ jQuery.extend({ // Otherwise, if a way to get the computed value exists, use that } else if ( curCSS ) { - return curCSS( elem, name, origName ); + return curCSS( elem, name ); } }, @@ -273,7 +279,7 @@ jQuery(function() { }); if ( document.defaultView && document.defaultView.getComputedStyle ) { - getComputedStyle = function( elem, newName, name ) { + getComputedStyle = function( elem, name ) { var ret, defaultView, computedStyle; name = name.replace( rupper, "-$1" ).toLowerCase(); diff --git a/test/unit/css.js b/test/unit/css.js index 08f50ef25..904312be6 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -377,3 +377,17 @@ test("marginRight computed style (bug #3333)", function() { equals($div.css("marginRight"), "0px"); }); + +test("jQuery.cssProps behavior, (bug #8402)", function() { + var div = jQuery( "
" ).appendTo(document.body).css({ + position: "absolute", + top: 0, + left: 10 + }); + jQuery.cssProps.top = "left"; + equal( div.css("top"), "10px", "the fixed property is used when accessing the computed style"); + div.css("top", "100px"); + equal( div[0].style.left, "100px", "the fixed property is used when setting the style"); + // cleanup jQuery.cssProps + jQuery.cssProps.top = undefined; +}); \ No newline at end of file -- cgit v1.2.3 From cccd092fe0c3e680b6ba3fcfb3368aa3b65bd245 Mon Sep 17 00:00:00 2001 From: louisremi Date: Mon, 11 Apr 2011 21:43:43 +0200 Subject: first batch --- src/css.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/css.js b/src/css.js index 65ec20f57..dfa820e22 100644 --- a/src/css.js +++ b/src/css.js @@ -93,7 +93,7 @@ jQuery.extend({ // convert relative number strings (+= or -=) to relative numbers. #7345 if ( type === "string" && rrelNum.test( value ) ) { - value = +value.replace( rrelNumFilter, '' ) + parseFloat( jQuery.css( elem, name ) ); + value = +value.replace( rrelNumFilter, "" ) + parseFloat( jQuery.css( elem, name ) ); } // If a number was passed in, add 'px' to the (except for certain CSS properties) @@ -245,7 +245,7 @@ if ( !jQuery.support.opacity ) { style.filter = ralpha.test(filter) ? filter.replace(ralpha, opacity) : - style.filter + ' ' + opacity; + style.filter + " " + opacity; } }; } -- cgit v1.2.3 From 581fa824200448361be534680a920d8144476aa7 Mon Sep 17 00:00:00 2001 From: louisremi Date: Mon, 11 Apr 2011 21:44:29 +0200 Subject: double quotes, again --- src/css.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/css.js b/src/css.js index 9fdba3b7b..e2c31c811 100644 --- a/src/css.js +++ b/src/css.js @@ -236,7 +236,7 @@ if ( !jQuery.support.opacity ) { style.filter = ralpha.test(filter) ? filter.replace(ralpha, opacity) : - filter + ' ' + opacity; + filter + " " + opacity; } }; } -- cgit v1.2.3 From 11adde5127ec496cf692237ea0d4f6217eac97b8 Mon Sep 17 00:00:00 2001 From: louisremi Date: Mon, 11 Apr 2011 22:33:29 +0200 Subject: second batch --- src/offset.js | 2 +- test/unit/ajax.js | 254 ++++++++++++++++----------------- test/unit/attributes.js | 364 ++++++++++++++++++++++++------------------------ test/unit/core.js | 138 +++++++++--------- test/unit/css.js | 116 +++++++-------- test/unit/data.js | 46 +++--- 6 files changed, 460 insertions(+), 460 deletions(-) (limited to 'src') diff --git a/src/offset.js b/src/offset.js index a0cd7a156..b9a132b42 100644 --- a/src/offset.js +++ b/src/offset.js @@ -180,7 +180,7 @@ jQuery.offset = { curOffset = curElem.offset(), curCSSTop = jQuery.css( elem, "top" ), curCSSLeft = jQuery.css( elem, "left" ), - calculatePosition = (position === "absolute" || position === "fixed") && jQuery.inArray('auto', [curCSSTop, curCSSLeft]) > -1, + calculatePosition = (position === "absolute" || position === "fixed") && jQuery.inArray("auto", [curCSSTop, curCSSLeft]) > -1, props = {}, curPosition = {}, curTop, curLeft; // need to be able to calculate position if either top or left is auto and position is either absolute or fixed diff --git a/test/unit/ajax.js b/test/unit/ajax.js index e9c7a00c5..ac1dc73b1 100644 --- a/test/unit/ajax.js +++ b/test/unit/ajax.js @@ -14,7 +14,7 @@ test("jQuery.ajax() - success callbacks", function() { stop(); - jQuery('#foo').ajaxStart(function(){ + jQuery("#foo").ajaxStart(function(){ ok( true, "ajaxStart" ); }).ajaxStop(function(){ ok( true, "ajaxStop" ); @@ -46,7 +46,7 @@ test("jQuery.ajax() - success callbacks - (url, options) syntax", function() { stop(); setTimeout(function(){ - jQuery('#foo').ajaxStart(function(){ + jQuery("#foo").ajaxStart(function(){ ok( true, "ajaxStart" ); }).ajaxStop(function(){ ok( true, "ajaxStop" ); @@ -78,7 +78,7 @@ test("jQuery.ajax() - success callbacks (late binding)", function() { stop(); setTimeout(function(){ - jQuery('#foo').ajaxStart(function(){ + jQuery("#foo").ajaxStart(function(){ ok( true, "ajaxStart" ); }).ajaxStop(function(){ ok( true, "ajaxStop" ); @@ -111,7 +111,7 @@ test("jQuery.ajax() - success callbacks (oncomplete binding)", function() { stop(); setTimeout(function(){ - jQuery('#foo').ajaxStart(function(){ + jQuery("#foo").ajaxStart(function(){ ok( true, "ajaxStart" ); }).ajaxStop(function(){ ok( true, "ajaxStop" ); @@ -147,7 +147,7 @@ test("jQuery.ajax() - success callbacks (very late binding)", function() { stop(); setTimeout(function(){ - jQuery('#foo').ajaxStart(function(){ + jQuery("#foo").ajaxStart(function(){ ok( true, "ajaxStart" ); }).ajaxStop(function(){ ok( true, "ajaxStop" ); @@ -214,7 +214,7 @@ test("jQuery.ajax() - error callbacks", function() { expect( 8 ); stop(); - jQuery('#foo').ajaxStart(function(){ + jQuery("#foo").ajaxStart(function(){ ok( true, "ajaxStart" ); }).ajaxStop(function(){ ok( true, "ajaxStop" ); @@ -247,10 +247,10 @@ test( "jQuery.ajax - multiple method signatures introduced in 1.5 ( #8107)", fun stop(); jQuery.when( - jQuery.ajax().success(function() { ok( true, 'With no arguments' ); }), - jQuery.ajax('data/name.html').success(function() { ok( true, 'With only string URL argument' ); }), - jQuery.ajax('data/name.html', {} ).success(function() { ok( true, 'With string URL param and map' ); }), - jQuery.ajax({ url: 'data/name.html'} ).success(function() { ok( true, 'With only map' ); }) + jQuery.ajax().success(function() { ok( true, "With no arguments" ); }), + jQuery.ajax("data/name.html").success(function() { ok( true, "With only string URL argument" ); }), + jQuery.ajax("data/name.html", {} ).success(function() { ok( true, "With string URL param and map" ); }), + jQuery.ajax({ url: "data/name.html"} ).success(function() { ok( true, "With only map" ); }) ).then( start, start ); }); @@ -348,7 +348,7 @@ test(".ajax() - headers" , function() { stop(); - jQuery('#foo').ajaxSend(function( evt, xhr ) { + jQuery("#foo").ajaxSend(function( evt, xhr ) { xhr.setRequestHeader( "ajax-send", "test" ); }); @@ -509,7 +509,7 @@ test("jQuery ajax - cross-domain detection", function() { jQuery.ajax({ dataType: "jsonp", - url: 'app:/path', + url: "app:/path", beforeSend: function( _ , s ) { ok( s.crossDomain , "Adobe AIR app:/ URL detected as cross-domain" ); return false; @@ -518,7 +518,7 @@ test("jQuery ajax - cross-domain detection", function() { jQuery.ajax({ dataType: "jsonp", - url: loc.protocol + '//somewebsitethatdoesnotexist-656329477541.com:' + ( loc.port || 80 ), + url: loc.protocol + "//somewebsitethatdoesnotexist-656329477541.com:" + ( loc.port || 80 ), beforeSend: function( _ , s ) { ok( s.crossDomain , "Test different hostnames are detected as cross-domain" ); return false; @@ -559,7 +559,7 @@ test(".load() - 404 error callbacks", function() { expect( 6 ); stop(); - jQuery('#foo').ajaxStart(function(){ + jQuery("#foo").ajaxStart(function(){ ok( true, "ajaxStart" ); }).ajaxStop(function(){ ok( true, "ajaxStop" ); @@ -583,7 +583,7 @@ test("jQuery.ajax() - abort", function() { expect( 8 ); stop(); - jQuery('#foo').ajaxStart(function(){ + jQuery("#foo").ajaxStart(function(){ ok( true, "ajaxStart" ); }).ajaxStop(function(){ ok( true, "ajaxStop" ); @@ -628,7 +628,7 @@ test("Ajax events with context", function() { }; } - jQuery('#foo').add(context) + jQuery("#foo").add(context) .ajaxSend(event) .ajaxComplete(event) .ajaxError(event) @@ -650,7 +650,7 @@ test("Ajax events with context", function() { complete: function(){ callback("complete").call(this); - jQuery('#foo').add(context).unbind(); + jQuery("#foo").add(context).unbind(); jQuery.ajax({ url: url("data/404.html"), @@ -734,7 +734,7 @@ test("jQuery.ajax() - disabled globals", function() { expect( 3 ); stop(); - jQuery('#foo').ajaxStart(function(){ + jQuery("#foo").ajaxStart(function(){ ok( false, "ajaxStart" ); }).ajaxStop(function(){ ok( false, "ajaxStop" ); @@ -768,9 +768,9 @@ test("jQuery.ajax - xml: non-namespace elements inside namespaced elements", fun url: url("data/with_fries.xml"), dataType: "xml", success: function(resp) { - equals( jQuery("properties", resp).length, 1, 'properties in responseXML' ); - equals( jQuery("jsconf", resp).length, 1, 'jsconf in responseXML' ); - equals( jQuery("thing", resp).length, 2, 'things in responseXML' ); + equals( jQuery("properties", resp).length, 1, "properties in responseXML" ); + equals( jQuery("jsconf", resp).length, 1, "jsconf in responseXML" ); + equals( jQuery("thing", resp).length, 2, "things in responseXML" ); start(); } }); @@ -783,9 +783,9 @@ test("jQuery.ajax - xml: non-namespace elements inside namespaced elements (over url: url("data/with_fries_over_jsonp.php"), dataType: "jsonp xml", success: function(resp) { - equals( jQuery("properties", resp).length, 1, 'properties in responseXML' ); - equals( jQuery("jsconf", resp).length, 1, 'jsconf in responseXML' ); - equals( jQuery("thing", resp).length, 2, 'things in responseXML' ); + equals( jQuery("properties", resp).length, 1, "properties in responseXML" ); + equals( jQuery("jsconf", resp).length, 1, "jsconf in responseXML" ); + equals( jQuery("thing", resp).length, 2, "things in responseXML" ); start(); }, error: function(_1,_2,error) { @@ -804,7 +804,7 @@ test("jQuery.ajax - HEAD requests", function() { type: "HEAD", success: function(data, status, xhr){ var h = xhr.getAllResponseHeaders(); - ok( /Date/i.test(h), 'No Date in HEAD response' ); + ok( /Date/i.test(h), "No Date in HEAD response" ); jQuery.ajax({ url: url("data/name.html"), @@ -812,7 +812,7 @@ test("jQuery.ajax - HEAD requests", function() { type: "HEAD", success: function(data, status, xhr){ var h = xhr.getAllResponseHeaders(); - ok( /Date/i.test(h), 'No Date in HEAD response with data' ); + ok( /Date/i.test(h), "No Date in HEAD response with data" ); start(); } }); @@ -891,8 +891,8 @@ test("jQuery.ajax - dataType html", function() { stop(); var verifyEvaluation = function() { - equals( testFoo, "foo", 'Check if script was evaluated for datatype html' ); - equals( foobar, "bar", 'Check if script src was evaluated for datatype html' ); + equals( testFoo, "foo", "Check if script was evaluated for datatype html" ); + equals( foobar, "bar", "Check if script src was evaluated for datatype html" ); start(); }; @@ -902,7 +902,7 @@ test("jQuery.ajax - dataType html", function() { url: url("data/test.html"), success: function(data) { jQuery("#ap").html(data); - ok( data.match(/^html text/), 'Check content for datatype html' ); + ok( data.match(/^html text/), "Check content for datatype html" ); setTimeout(verifyEvaluation, 600); } }); @@ -913,34 +913,34 @@ test("serialize()", function() { // Add html5 elements only for serialize because selector can't yet find them on non-html5 browsers jQuery("#search").after( - ''+ - '' + ""+ + "" ); - equals( jQuery('#form').serialize(), + equals( jQuery("#form").serialize(), "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3", - 'Check form serialization as query string'); + "Check form serialization as query string"); - equals( jQuery('#form :input').serialize(), + equals( jQuery("#form :input").serialize(), "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3", - 'Check input serialization as query string'); + "Check input serialization as query string"); - equals( jQuery('#testForm').serialize(), - 'T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=', - 'Check form serialization as query string'); + equals( jQuery("#testForm").serialize(), + "T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=", + "Check form serialization as query string"); - equals( jQuery('#testForm :input').serialize(), - 'T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=', - 'Check input serialization as query string'); + equals( jQuery("#testForm :input").serialize(), + "T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=", + "Check input serialization as query string"); - equals( jQuery('#form, #testForm').serialize(), + equals( jQuery("#form, #testForm").serialize(), "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&select5=3&T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=", - 'Multiple form serialization as query string'); + "Multiple form serialization as query string"); /* Temporarily disabled. Opera 10 has problems with form serialization. - equals( jQuery('#form, #testForm :input').serialize(), + equals( jQuery("#form, #testForm :input").serialize(), "action=Test&radio2=on&check=on&hidden=&foo%5Bbar%5D=&name=name&search=search&email=dave%40jquery.com&number=43&select1=&select2=3&select3=1&select3=2&T3=%3F%0D%0AZ&H1=x&H2=&PWD=&T1=&T2=YES&My+Name=me&S1=abc&S3=YES&S4=", - 'Mixed form/input serialization as query string'); + "Mixed form/input serialization as query string"); */ jQuery("#html5email, #html5number").remove(); }); @@ -956,13 +956,13 @@ test("jQuery.param()", function() { params = {someName: [1, 2, 3], regularThing: "blah" }; equals( jQuery.param(params), "someName%5B%5D=1&someName%5B%5D=2&someName%5B%5D=3®ularThing=blah", "with array" ); - params = {foo: ['a', 'b', 'c']}; + params = {foo: ["a", "b", "c"]}; equals( jQuery.param(params), "foo%5B%5D=a&foo%5B%5D=b&foo%5B%5D=c", "with array of strings" ); params = {foo: ["baz", 42, "All your base are belong to us"] }; equals( jQuery.param(params), "foo%5B%5D=baz&foo%5B%5D=42&foo%5B%5D=All+your+base+are+belong+to+us", "more array" ); - params = {foo: { bar: 'baz', beep: 42, quux: 'All your base are belong to us' } }; + params = {foo: { bar: "baz", beep: 42, quux: "All your base are belong to us" } }; equals( jQuery.param(params), "foo%5Bbar%5D=baz&foo%5Bbeep%5D=42&foo%5Bquux%5D=All+your+base+are+belong+to+us", "even more arrays" ); params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" }; @@ -974,7 +974,7 @@ test("jQuery.param()", function() { params = { a:[1,2], b:{ c:3, d:[4,5], e:{ x:[6], y:7, z:[8,9] }, f:true, g:false, h:undefined }, i:[10,11], j:true, k:false, l:[undefined,0], m:"cowboy hat?" }; equals( jQuery.param(params,true), "a=1&a=2&b=%5Bobject+Object%5D&i=10&i=11&j=true&k=false&l=undefined&l=0&m=cowboy+hat%3F", "huge structure, forced traditional" ); - equals( decodeURIComponent( jQuery.param({ a: [1,2,3], 'b[]': [4,5,6], 'c[d]': [7,8,9], e: { f: [10], g: [11,12], h: 13 } }) ), "a[]=1&a[]=2&a[]=3&b[]=4&b[]=5&b[]=6&c[d][]=7&c[d][]=8&c[d][]=9&e[f][]=10&e[g][]=11&e[g][]=12&e[h]=13", "Make sure params are not double-encoded." ); + equals( decodeURIComponent( jQuery.param({ a: [1,2,3], "b[]": [4,5,6], "c[d]": [7,8,9], e: { f: [10], g: [11,12], h: 13 } }) ), "a[]=1&a[]=2&a[]=3&b[]=4&b[]=5&b[]=6&c[d][]=7&c[d][]=8&c[d][]=9&e[f][]=10&e[g][]=11&e[g][]=12&e[h]=13", "Make sure params are not double-encoded." ); // Make sure empty arrays and objects are handled #6481 equals( jQuery.param({"foo": {"bar": []} }), "foo%5Bbar%5D=", "Empty array param" ); @@ -992,7 +992,7 @@ test("jQuery.param()", function() { params = {someName: [1, 2, 3], regularThing: "blah" }; equals( jQuery.param(params), "someName=1&someName=2&someName=3®ularThing=blah", "with array" ); - params = {foo: ['a', 'b', 'c']}; + params = {foo: ["a", "b", "c"]}; equals( jQuery.param(params), "foo=a&foo=b&foo=c", "with array of strings" ); params = {"foo[]":["baz", 42, "All your base are belong to us"]}; @@ -1013,7 +1013,7 @@ test("jQuery.param()", function() { params = { param1: null }; equals( jQuery.param(params,false), "param1=null", "Make sure that null params aren't traversed." ); - params = {'test': {'length': 3, 'foo': 'bar'} }; + params = {"test": {"length": 3, "foo": "bar"} }; equals( jQuery.param( params, false ), "test%5Blength%5D=3&test%5Bfoo%5D=bar", "Sub-object with a length property" ); }); @@ -1044,10 +1044,10 @@ test("pass-through request object", function() { errorCount++; errorEx += ": " + xml.status; }); - jQuery("#foo").one('ajaxStop', function () { + jQuery("#foo").one("ajaxStop", function () { equals(successCount, 5, "Check all ajax calls successful"); equals(errorCount, 0, "Check no ajax errors (status" + errorEx + ")"); - jQuery("#foo").unbind('ajaxError'); + jQuery("#foo").unbind("ajaxError"); start(); }); @@ -1101,17 +1101,17 @@ test("global ajaxSettings", function() { var orig = { url: "data/with_fries.xml" }; var t; - jQuery.ajaxSetup({ data: {foo: 'bar', bar: 'BAR'} }); + jQuery.ajaxSetup({ data: {foo: "bar", bar: "BAR"} }); t = jQuery.extend({}, orig); t.data = {}; jQuery.ajax(t); - ok( t.url.indexOf('foo') > -1 && t.url.indexOf('bar') > -1, "Check extending {}" ); + ok( t.url.indexOf("foo") > -1 && t.url.indexOf("bar") > -1, "Check extending {}" ); t = jQuery.extend({}, orig); - t.data = { zoo: 'a', ping: 'b' }; + t.data = { zoo: "a", ping: "b" }; jQuery.ajax(t); - ok( t.url.indexOf('ping') > -1 && t.url.indexOf('zoo') > -1 && t.url.indexOf('foo') > -1 && t.url.indexOf('bar') > -1, "Check extending { zoo: 'a', ping: 'b' }" ); + ok( t.url.indexOf("ping") > -1 && t.url.indexOf("zoo") > -1 && t.url.indexOf("foo") > -1 && t.url.indexOf("bar") > -1, "Check extending { zoo: "a", ping: "b" }" ); jQuery.ajaxSettings = tmp; }); @@ -1120,13 +1120,13 @@ test("global ajaxSettings", function() { test("load(String)", function() { expect(1); stop(); // check if load can be called with only url - jQuery('#first').load("data/name.html", start); + jQuery("#first").load("data/name.html", start); }); test("load('url selector')", function() { expect(1); stop(); // check if load can be called with only url - jQuery('#first').load("data/test3.html div.user", function(){ + jQuery("#first").load("data/test3.html div.user", function(){ equals( jQuery(this).children("div").length, 2, "Verify that specific elements were injected" ); start(); }); @@ -1142,14 +1142,14 @@ test("load(String, Function) with ajaxSetup on dataType json, see #2046", functi jQuery.ajaxSetup({ dataType: "" }); start(); }); - jQuery('#first').load("data/test3.html"); + jQuery("#first").load("data/test3.html"); }); test("load(String, Function) - simple: inject text into DOM", function() { expect(2); stop(); - jQuery('#first').load(url("data/name.html"), function() { - ok( /^ERROR/.test(jQuery('#first').text()), 'Check if content was injected into the DOM' ); + jQuery("#first").load(url("data/name.html"), function() { + ok( /^ERROR/.test(jQuery("#first").text()), "Check if content was injected into the DOM" ); start(); }); }); @@ -1159,15 +1159,15 @@ test("load(String, Function) - check scripts", function() { stop(); var verifyEvaluation = function() { - equals( foobar, "bar", 'Check if script src was evaluated after load' ); - equals( jQuery('#ap').html(), 'bar', 'Check if script evaluation has modified DOM'); + equals( foobar, "bar", "Check if script src was evaluated after load" ); + equals( jQuery("#ap").html(), "bar", "Check if script evaluation has modified DOM"); start(); }; - jQuery('#first').load(url('data/test.html'), function() { - ok( jQuery('#first').html().match(/^html text/), 'Check content after loading html' ); - equals( jQuery('#foo').html(), 'foo', 'Check if script evaluation has modified DOM'); - equals( testFoo, "foo", 'Check if script was evaluated after load' ); + jQuery("#first").load(url("data/test.html"), function() { + ok( jQuery("#first").html().match(/^html text/), "Check content after loading html" ); + equals( jQuery("#foo").html(), "foo", "Check if script evaluation has modified DOM"); + equals( testFoo, "foo", "Check if script was evaluated after load" ); setTimeout(verifyEvaluation, 600); }); }); @@ -1176,9 +1176,9 @@ test("load(String, Function) - check file with only a script tag", function() { expect(3); stop(); - jQuery('#first').load(url('data/test2.html'), function() { - equals( jQuery('#foo').html(), 'foo', 'Check if script evaluation has modified DOM'); - equals( testFoo, "foo", 'Check if script was evaluated after load' ); + jQuery("#first").load(url("data/test2.html"), function() { + equals( jQuery("#foo").html(), "foo", "Check if script evaluation has modified DOM"); + equals( testFoo, "foo", "Check if script was evaluated after load" ); start(); }); @@ -1200,10 +1200,10 @@ test("load(String, Object, Function)", function() { expect(2); stop(); - jQuery('
').load(url('data/params_html.php'), { foo:3, bar:'ok' }, function() { - var $post = jQuery(this).find('#post'); - equals( $post.find('#foo').text(), '3', 'Check if a hash of data is passed correctly'); - equals( $post.find('#bar').text(), 'ok', 'Check if a hash of data is passed correctly'); + jQuery("
").load(url("data/params_html.php"), { foo: 3, bar: "ok" }, function() { + var $post = jQuery(this).find("#post"); + equals( $post.find("#foo").text(), "3", "Check if a hash of data is passed correctly"); + equals( $post.find("#bar").text(), "ok", "Check if a hash of data is passed correctly"); start(); }); }); @@ -1212,10 +1212,10 @@ test("load(String, String, Function)", function() { expect(2); stop(); - jQuery('
').load(url('data/params_html.php'), 'foo=3&bar=ok', function() { - var $get = jQuery(this).find('#get'); - equals( $get.find('#foo').text(), '3', 'Check if a string of data is passed correctly'); - equals( $get.find('#bar').text(), 'ok', 'Check if a of data is passed correctly'); + jQuery("
").load(url("data/params_html.php"), "foo=3&bar=ok", function() { + var $get = jQuery(this).find("#get"); + equals( $get.find("#foo").text(), "3", "Check if a string of data is passed correctly"); + equals( $get.find("#bar").text(), "ok", "Check if a of data is passed correctly"); start(); }); }); @@ -1226,8 +1226,8 @@ test("jQuery.get(String, Function) - data in ajaxSettings (#8277)", function() { jQuery.ajaxSetup({ data: "helloworld" }); - jQuery.get(url('data/echoQuery.php'), function(data) { - ok( /helloworld$/.test( data ), 'Data from ajaxSettings was used'); + jQuery.get(url("data/echoQuery.php"), function(data) { + ok( /helloworld$/.test( data ), "Data from ajaxSettings was used"); jQuery.ajaxSetup({ data: null }); @@ -1238,13 +1238,13 @@ test("jQuery.get(String, Function) - data in ajaxSettings (#8277)", function() { test("jQuery.get(String, Hash, Function) - parse xml and use text() on nodes", function() { expect(2); stop(); - jQuery.get(url('data/dashboard.xml'), function(xml) { + jQuery.get(url("data/dashboard.xml"), function(xml) { var content = []; - jQuery('tab', xml).each(function() { + jQuery("tab", xml).each(function() { content.push(jQuery(this).text()); }); - equals( content[0], 'blabla', 'Check first tab'); - equals( content[1], 'blublu', 'Check second tab'); + equals( content[0], "blabla", "Check first tab"); + equals( content[1], "blublu", "Check second tab"); start(); }); }); @@ -1253,7 +1253,7 @@ test("jQuery.getScript(String, Function) - with callback", function() { expect(3); stop(); jQuery.getScript(url("data/test.js"), function( data, _, jqXHR ) { - equals( foobar, "bar", 'Check if script was evaluated' ); + equals( foobar, "bar", "Check if script was evaluated" ); strictEqual( data, jqXHR.responseText, "Same-domain script requests returns the source of the script (#8082)" ); setTimeout(start, 100); }); @@ -1636,10 +1636,10 @@ test("jQuery.ajax() - json by content-type", function() { data: { header: "json", json: "array" }, success: function( json ) { ok( json.length >= 2, "Check length"); - equals( json[0].name, 'John', 'Check JSON: first, name' ); - equals( json[0].age, 21, 'Check JSON: first, age' ); - equals( json[1].name, 'Peter', 'Check JSON: second, name' ); - equals( json[1].age, 25, 'Check JSON: second, age' ); + equals( json[0].name, "John", "Check JSON: first, name" ); + equals( json[0].age, 21, "Check JSON: first, age" ); + equals( json[1].name, "Peter", "Check JSON: second, name" ); + equals( json[1].age, 25, "Check JSON: second, age" ); start(); } }); @@ -1660,10 +1660,10 @@ test("jQuery.ajax() - json by content-type disabled with options", function() { equals( typeof text , "string" , "json wasn't auto-determined" ); var json = jQuery.parseJSON( text ); ok( json.length >= 2, "Check length"); - equals( json[0].name, 'John', 'Check JSON: first, name' ); - equals( json[0].age, 21, 'Check JSON: first, age' ); - equals( json[1].name, 'Peter', 'Check JSON: second, name' ); - equals( json[1].age, 25, 'Check JSON: second, age' ); + equals( json[0].name, "John", "Check JSON: first, name" ); + equals( json[0].age, 21, "Check JSON: first, age" ); + equals( json[1].name, "Peter", "Check JSON: second, name" ); + equals( json[1].age, 25, "Check JSON: second, age" ); start(); } }); @@ -1674,10 +1674,10 @@ test("jQuery.getJSON(String, Hash, Function) - JSON array", function() { stop(); jQuery.getJSON(url("data/json.php"), {json: "array"}, function(json) { ok( json.length >= 2, "Check length"); - equals( json[0].name, 'John', 'Check JSON: first, name' ); - equals( json[0].age, 21, 'Check JSON: first, age' ); - equals( json[1].name, 'Peter', 'Check JSON: second, name' ); - equals( json[1].age, 25, 'Check JSON: second, age' ); + equals( json[0].name, "John", "Check JSON: first, name" ); + equals( json[0].age, 21, "Check JSON: first, age" ); + equals( json[1].name, "Peter", "Check JSON: second, name" ); + equals( json[1].age, 25, "Check JSON: second, age" ); start(); }); }); @@ -1687,8 +1687,8 @@ test("jQuery.getJSON(String, Function) - JSON object", function() { stop(); jQuery.getJSON(url("data/json.php"), function(json) { if (json && json.data) { - equals( json.data.lang, 'en', 'Check JSON: lang' ); - equals( json.data.length, 25, 'Check JSON: length' ); + equals( json.data.lang, "en", "Check JSON: lang" ); + equals( json.data.length, 25, "Check JSON: length" ); } start(); }); @@ -1720,8 +1720,8 @@ test("jQuery.getJSON(String, Function) - JSON object with absolute url to local stop(); jQuery.getJSON(url(base + "data/json.php"), function(json) { - equals( json.data.lang, 'en', 'Check JSON: lang' ); - equals( json.data.length, 25, 'Check JSON: length' ); + equals( json.data.lang, "en", "Check JSON: lang" ); + equals( json.data.length, 25, "Check JSON: length" ); start(); }); }); @@ -1731,23 +1731,23 @@ test("jQuery.post - data", 3, function() { jQuery.when( jQuery.post( url( "data/name.php" ), { xml: "5-2", length: 3 }, function( xml ) { - jQuery( 'math', xml ).each( function() { - equals( jQuery( 'calculation', this ).text(), '5-2', 'Check for XML' ); - equals( jQuery( 'result', this ).text(), '3', 'Check for XML' ); + jQuery( "math", xml ).each( function() { + equals( jQuery( "calculation", this ).text(), "5-2", "Check for XML" ); + equals( jQuery( "result", this ).text(), "3", "Check for XML" ); }); }), jQuery.ajax({ - url: url('data/echoData.php'), + url: url("data/echoData.php"), type: "POST", data: { - 'test': { - 'length': 7, - 'foo': 'bar' + "test": { + "length": 7, + "foo": "bar" } }, success: function( data ) { - strictEqual( data, 'test%5Blength%5D=7&test%5Bfoo%5D=bar', 'Check if a sub-object with a length param is serialized correctly'); + strictEqual( data, "test%5Blength%5D=7&test%5Bfoo%5D=bar", "Check if a sub-object with a length param is serialized correctly"); } }) ).then( start, start ); @@ -1760,17 +1760,17 @@ test("jQuery.post(String, Hash, Function) - simple with xml", function() { var done = 0; jQuery.post(url("data/name.php"), {xml: "5-2"}, function(xml){ - jQuery('math', xml).each(function() { - equals( jQuery('calculation', this).text(), '5-2', 'Check for XML' ); - equals( jQuery('result', this).text(), '3', 'Check for XML' ); + jQuery("math", xml).each(function() { + equals( jQuery("calculation", this).text(), "5-2", "Check for XML" ); + equals( jQuery("result", this).text(), "3", "Check for XML" ); }); if ( ++done === 2 ) start(); }); jQuery.post(url("data/name.php?xml=5-2"), {}, function(xml){ - jQuery('math', xml).each(function() { - equals( jQuery('calculation', this).text(), '5-2', 'Check for XML' ); - equals( jQuery('result', this).text(), '3', 'Check for XML' ); + jQuery("math", xml).each(function() { + equals( jQuery("calculation", this).text(), "5-2", "Check for XML" ); + equals( jQuery("result", this).text(), "3", "Check for XML" ); }); if ( ++done === 2 ) start(); }); @@ -1786,18 +1786,18 @@ test("jQuery.ajaxSetup({timeout: Number}) - with global timeout", function() { var pass = function() { passed++; if ( passed == 2 ) { - ok( true, 'Check local and global callbacks after timeout' ); - jQuery('#main').unbind("ajaxError"); + ok( true, "Check local and global callbacks after timeout" ); + jQuery("#main").unbind("ajaxError"); start(); } }; var fail = function(a,b,c) { - ok( false, 'Check for timeout failed ' + a + ' ' + b ); + ok( false, "Check for timeout failed " + a + " " + b ); start(); }; - jQuery('#main').ajaxError(pass); + jQuery("#main").ajaxError(pass); jQuery.ajax({ type: "GET", @@ -1819,11 +1819,11 @@ test("jQuery.ajaxSetup({timeout: Number}) with localtimeout", function() { timeout: 15000, url: url("data/name.php?wait=1"), error: function() { - ok( false, 'Check for local timeout failed' ); + ok( false, "Check for local timeout failed" ); start(); }, success: function() { - ok( true, 'Check for local timeout' ); + ok( true, "Check for local timeout" ); start(); } }); @@ -1839,7 +1839,7 @@ test("jQuery.ajax - simple get", function() { type: "GET", url: url("data/name.php?name=foo"), success: function(msg){ - equals( msg, 'bar', 'Check for GET' ); + equals( msg, "bar", "Check for GET" ); start(); } }); @@ -1853,7 +1853,7 @@ test("jQuery.ajax - simple post", function() { url: url("data/name.php"), data: "name=peter", success: function(msg){ - equals( msg, 'pan', 'Check for POST' ); + equals( msg, "pan", "Check for POST" ); start(); } }); @@ -1865,7 +1865,7 @@ test("ajaxSetup()", function() { jQuery.ajaxSetup({ url: url("data/name.php?name=foo"), success: function(msg){ - equals( msg, 'bar', 'Check for GET' ); + equals( msg, "bar", "Check for GET" ); start(); } }); @@ -2027,14 +2027,14 @@ test("jQuery ajax - failing cross-domain", function() { var i = 2; jQuery.ajax({ - url: 'http://somewebsitethatdoesnotexist-67864863574657654.com', + url: "http://somewebsitethatdoesnotexist-67864863574657654.com", success: function(){ ok( false , "success" ); }, error: function(xhr,_,e){ ok( true , "file not found: " + xhr.status + " => " + e ); }, complete: function() { if ( ! --i ) start(); } }); jQuery.ajax({ - url: 'http://www.google.com', + url: "http://www.google.com", success: function(){ ok( false , "success" ); }, error: function(xhr,_,e){ ok( true , "access denied: " + xhr.status + " => " + e ); }, complete: function() { if ( ! --i ) start(); } @@ -2047,7 +2047,7 @@ test("jQuery ajax - atom+xml", function() { stop(); jQuery.ajax({ - url: url( 'data/atom+xml.php' ), + url: url( "data/atom+xml.php" ), success: function(){ ok( true , "success" ); }, error: function(){ ok( false , "error" ); }, complete: function() { start(); } diff --git a/test/unit/attributes.js b/test/unit/attributes.js index f3f0bab2b..c78a2961f 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -37,19 +37,19 @@ test("jQuery.attrFix integrity test", function() { test("prop(String, Object)", function() { expect(19); - equals( jQuery('#text1').prop('value'), "Test", 'Check for value attribute' ); - equals( jQuery('#text1').prop('value', "Test2").prop('defaultValue'), "Test", 'Check for defaultValue attribute' ); - equals( jQuery('#select2').prop('selectedIndex'), 3, 'Check for selectedIndex attribute' ); - equals( jQuery('#foo').prop('nodeName').toUpperCase(), 'DIV', 'Check for nodeName attribute' ); - equals( jQuery('#foo').prop('tagName').toUpperCase(), 'DIV', 'Check for tagName attribute' ); + equals( jQuery("#text1").prop("value"), "Test", "Check for value attribute" ); + equals( jQuery("#text1").prop("value", "Test2").prop("defaultValue"), "Test", "Check for defaultValue attribute" ); + equals( jQuery("#select2").prop("selectedIndex"), 3, "Check for selectedIndex attribute" ); + equals( jQuery("#foo").prop("nodeName").toUpperCase(), "DIV", "Check for nodeName attribute" ); + equals( jQuery("#foo").prop("tagName").toUpperCase(), "DIV", "Check for tagName attribute" ); equals( jQuery("').attr({ 'id': 'tAnchor5', 'href': '#5' }).appendTo('#main'); - equals( jQuery('#tAnchor5').attr('href'), "#5", 'Check for non-absolute href (an anchor)' ); + jQuery("").attr({ "id": "tAnchor5", "href": "#5" }).appendTo("#main"); + equals( jQuery("#tAnchor5").attr("href"), "#5", "Check for non-absolute href (an anchor)" ); // list attribute is readonly by default in browsers that support it - jQuery('#list-test').attr('list', 'datalist'); - equals( jQuery('#list-test').attr('list'), 'datalist', 'Check setting list attribute' ); + jQuery("#list-test").attr("list", "datalist"); + equals( jQuery("#list-test").attr("list"), "datalist", "Check setting list attribute" ); // Related to [5574] and [5683] var body = document.body, $body = jQuery(body); - strictEqual( $body.attr('foo'), undefined, 'Make sure that a non existent attribute returns undefined' ); + strictEqual( $body.attr("foo"), undefined, "Make sure that a non existent attribute returns undefined" ); - body.setAttribute('foo', 'baz'); - equals( $body.attr('foo'), 'baz', 'Make sure the dom attribute is retrieved when no expando is found' ); + body.setAttribute("foo", "baz"); + equals( $body.attr("foo"), "baz", "Make sure the dom attribute is retrieved when no expando is found" ); - $body.attr('foo','cool'); - equals( $body.attr('foo'), 'cool', 'Make sure that setting works well when both expando and dom attribute are available' ); + $body.attr("foo","cool"); + equals( $body.attr("foo"), "cool", "Make sure that setting works well when both expando and dom attribute are available" ); - body.removeAttribute('foo'); // Cleanup + body.removeAttribute("foo"); // Cleanup - var $img = jQuery('').appendTo('body'); - equals( $img.attr('width'), "215", "Retrieve width attribute an an element with display:none." ); - equals( $img.attr('height'), "53", "Retrieve height attribute an an element with display:none." ); + var $img = jQuery("").appendTo("body"); + equals( $img.attr("width"), "215", "Retrieve width attribute an an element with display:none." ); + equals( $img.attr("height"), "53", "Retrieve height attribute an an element with display:none." ); // Check for style support - ok( !!~jQuery('#dl').attr('style').indexOf('position'), 'Check style attribute getter, also normalize css props to lowercase' ); - ok( !!~jQuery('#foo').attr('style', 'position:absolute;').attr('style').indexOf('position'), 'Check style setter' ); + ok( !!~jQuery("#dl").attr("style").indexOf("position"), "Check style attribute getter, also normalize css props to lowercase" ); + ok( !!~jQuery("#foo").attr("style", "position:absolute;").attr("style").indexOf("position"), "Check style setter" ); ok( jQuery("
").attr("doesntexist") === undefined, "Make sure undefined is returned when no attribute is found." ); ok( jQuery().attr("doesntexist") === undefined, "Make sure undefined is returned when no element is there." ); @@ -153,19 +153,19 @@ if ( !isLocal ) { test("attr(String, Function)", function() { expect(2); - equals( jQuery('#text1').attr('value', function() { return this.id; })[0].value, "text1", "Set value from id" ); - equals( jQuery('#text1').attr('title', function(i) { return i; }).attr('title'), "0", "Set value with an index"); + equals( jQuery("#text1").attr("value", function() { return this.id; })[0].value, "text1", "Set value from id" ); + equals( jQuery("#text1").attr("title", function(i) { return i; }).attr("title"), "0", "Set value with an index"); }); test("attr(Hash)", function() { expect(3); var pass = true; - jQuery("div").attr({foo: 'baz', zoo: 'ping'}).each(function(){ - if ( this.getAttribute('foo') != "baz" && this.getAttribute('zoo') != "ping" ) pass = false; + jQuery("div").attr({foo: "baz", zoo: "ping"}).each(function(){ + if ( this.getAttribute("foo") != "baz" && this.getAttribute("zoo") != "ping" ) pass = false; }); ok( pass, "Set Multiple Attributes" ); - equals( jQuery('#text1').attr({'value': function() { return this.id; }})[0].value, "text1", "Set attribute to computed value #1" ); - equals( jQuery('#text1').attr({'title': function(i) { return i; }}).attr('title'), "0", "Set attribute to computed value #2"); + equals( jQuery("#text1").attr({value: function() { return this.id; }})[0].value, "text1", "Set attribute to computed value #1" ); + equals( jQuery("#text1").attr({title: function(i) { return i; }}).attr("title"), "0", "Set attribute to computed value #2"); }); @@ -176,7 +176,7 @@ test("attr(String, Object)", function() { fail = false; for ( var i = 0; i < div.size(); i++ ) { - if ( div.get(i).getAttribute('foo') != "bar" ){ + if ( div.get(i).getAttribute("foo") != "bar" ){ fail = i; break; } @@ -187,25 +187,25 @@ test("attr(String, Object)", function() { // Fails on IE since recent changes to .attr() // ok( jQuery("#foo").attr({"width": null}), "Try to set an attribute to nothing" ); - jQuery("#name").attr('name', 'something'); - equals( jQuery("#name").attr('name'), 'something', 'Set name attribute' ); - jQuery("#name").attr('name', null); - equals( jQuery("#name").attr('name'), undefined, 'Remove name attribute' ); - jQuery("#check2").attr('checked', true); - equals( document.getElementById('check2').checked, true, 'Set checked attribute' ); - jQuery("#check2").attr('checked', false); - equals( document.getElementById('check2').checked, false, 'Set checked attribute' ); - jQuery("#text1").attr('readonly', true); - equals( document.getElementById('text1').readOnly, true, 'Set readonly attribute' ); - jQuery("#text1").attr('readonly', false); - equals( document.getElementById('text1').readOnly, false, 'Set readonly attribute' ); - jQuery("#name").attr('maxlength', '5'); - equals( document.getElementById('name').maxLength, 5, 'Set maxlength attribute' ); - jQuery("#name").attr('maxLength', '10'); - equals( document.getElementById('name').maxLength, 10, 'Set maxlength attribute' ); - var $p = jQuery('#firstp').attr('nonexisting', 'foo'); - equals( $p.attr('nonexisting'), 'foo', "attr(name, value) works correctly for non existing attributes (bug #7500)."); - $p.removeAttr('nonexisting'); + jQuery("#name").attr("name", "something"); + equals( jQuery("#name").attr("name"), "something", "Set name attribute" ); + jQuery("#name").attr("name", null); + equals( jQuery("#name").attr("name"), undefined, "Remove name attribute" ); + jQuery("#check2").attr("checked", true); + equals( document.getElementById("check2").checked, true, "Set checked attribute" ); + jQuery("#check2").attr("checked", false); + equals( document.getElementById("check2").checked, false, "Set checked attribute" ); + jQuery("#text1").attr("readonly", true); + equals( document.getElementById("text1").readOnly, true, "Set readonly attribute" ); + jQuery("#text1").attr("readonly", false); + equals( document.getElementById("text1").readOnly, false, "Set readonly attribute" ); + jQuery("#name").attr("maxlength", "5"); + equals( document.getElementById("name").maxLength, 5, "Set maxlength attribute" ); + jQuery("#name").attr("maxLength", "10"); + equals( document.getElementById("name").maxLength, 10, "Set maxlength attribute" ); + var $p = jQuery("#firstp").attr("nonexisting", "foo"); + equals( $p.attr("nonexisting"), "foo", "attr(name, value) works correctly for non existing attributes (bug #7500)."); + $p.removeAttr("nonexisting"); var attributeNode = document.createAttribute("irrelevant"), commentNode = document.createComment("some comment"), @@ -217,8 +217,8 @@ test("attr(String, Object)", function() { strictEqual( $ele.attr("nonexisting"), undefined, "attr(name, value) works correctly on comment and text nodes (bug #7500)." ); }); - var table = jQuery('#table').append("cellcellcellcellcell"), - td = table.find('td:first'); + var table = jQuery("#table").append("cellcellcellcellcell"), + td = table.find("td:first"); td.attr("rowspan", "2"); equals( td[0].rowSpan, 2, "Check rowspan is correctly set" ); td.attr("colspan", "2"); @@ -227,12 +227,12 @@ test("attr(String, Object)", function() { equals( table[0].cellSpacing, "2", "Check cellspacing is correctly set" ); // for #1070 - jQuery("#name").attr('someAttr', '0'); - equals( jQuery("#name").attr('someAttr'), '0', 'Set attribute to a string of "0"' ); - jQuery("#name").attr('someAttr', 0); - equals( jQuery("#name").attr('someAttr'), '0', 'Set attribute to the number 0' ); - jQuery("#name").attr('someAttr', 1); - equals( jQuery("#name").attr('someAttr'), '1', 'Set attribute to the number 1' ); + jQuery("#name").attr("someAttr", "0"); + equals( jQuery("#name").attr("someAttr"), "0", "Set attribute to a string of \"0\"" ); + jQuery("#name").attr("someAttr", 0); + equals( jQuery("#name").attr("someAttr"), "0", "Set attribute to the number 0" ); + jQuery("#name").attr("someAttr", 1); + equals( jQuery("#name").attr("someAttr"), "1", "Set attribute to the number 1" ); // using contents will get comments regular, text, and comment nodes var j = jQuery("#nonnodes").contents(); @@ -244,51 +244,51 @@ test("attr(String, Object)", function() { QUnit.reset(); // Type - var type = jQuery("#check2").attr('type'); + var type = jQuery("#check2").attr("type"); var thrown = false; try { - jQuery("#check2").attr('type','hidden'); + jQuery("#check2").attr("type","hidden"); } catch(e) { thrown = true; } ok( thrown, "Exception thrown when trying to change type property" ); - equals( type, jQuery("#check2").attr('type'), "Verify that you can't change the type of an input element" ); + equals( type, jQuery("#check2").attr("type"), "Verify that you can't change the type of an input element" ); var check = document.createElement("input"); var thrown = true; try { - jQuery(check).attr('type','checkbox'); + jQuery(check).attr("type", "checkbox"); } catch(e) { thrown = false; } ok( thrown, "Exception thrown when trying to change type property" ); - equals( "checkbox", jQuery(check).attr('type'), "Verify that you can change the type of an input element that isn't in the DOM" ); + equals( "checkbox", jQuery(check).attr("type"), "Verify that you can change the type of an input element that isn't in the DOM" ); var check = jQuery(""); var thrown = true; try { - check.attr('type','checkbox'); + check.attr("type","checkbox"); } catch(e) { thrown = false; } ok( thrown, "Exception thrown when trying to change type property" ); - equals( "checkbox", check.attr('type'), "Verify that you can change the type of an input element that isn't in the DOM" ); + equals( "checkbox", check.attr("type"), "Verify that you can change the type of an input element that isn't in the DOM" ); var button = jQuery("#button"); var thrown = false; try { - button.attr('type','submit'); + button.attr("type","submit"); } catch(e) { thrown = true; } ok( thrown, "Exception thrown when trying to change type property" ); - equals( "button", button.attr('type'), "Verify that you can't change the type of a button element" ); + equals( "button", button.attr("type"), "Verify that you can't change the type of a button element" ); // Setting attributes on svg elements (bug #3116) - var $svg = jQuery('' - + '' - + '').appendTo('body'); - equals( $svg.attr('cx', 100).attr('cx'), "100", "Set attribute on svg element" ); + var $svg = jQuery("" + + "" + + "").appendTo("body"); + equals( $svg.attr("cx", 100).attr("cx"), "100", "Set attribute on svg element" ); $svg.remove(); }); @@ -299,17 +299,17 @@ test("attr(jquery_method)", function(){ elem = $elem[0]; // one at a time - $elem.attr({'html': 'foo'}, true); - equals( elem.innerHTML, 'foo', 'attr(html)'); + $elem.attr({html: "foo"}, true); + equals( elem.innerHTML, "foo", "attr(html)"); - $elem.attr({'text': 'bar'}, true); - equals( elem.innerHTML, 'bar', 'attr(text)'); + $elem.attr({text: "bar"}, true); + equals( elem.innerHTML, "bar", "attr(text)"); - $elem.attr({'css': {color:'red'}}, true); - ok( /^(#ff0000|red)$/i.test(elem.style.color), 'attr(css)'); + $elem.attr({css: {color: "red"}}, true); + ok( /^(#ff0000|red)$/i.test(elem.style.color), "attr(css)"); - $elem.attr({'height': 10}, true); - equals( elem.style.height, '10px', 'attr(height)'); + $elem.attr({height: 10}, true); + equals( elem.style.height, "10px", "attr(height)"); // Multiple attributes @@ -318,22 +318,22 @@ test("attr(jquery_method)", function(){ css:{ paddingLeft:1, paddingRight:1 } }, true); - equals( elem.style.width, '10px', 'attr({...})'); - equals( elem.style.paddingLeft, '1px', 'attr({...})'); - equals( elem.style.paddingRight, '1px', 'attr({...})'); + equals( elem.style.width, "10px", "attr({...})"); + equals( elem.style.paddingLeft, "1px", "attr({...})"); + equals( elem.style.paddingRight, "1px", "attr({...})"); }); if ( !isLocal ) { test("attr(String, Object) - Loaded via XML document", function() { expect(2); stop(); - jQuery.get('data/dashboard.xml', function(xml) { + jQuery.get("data/dashboard.xml", function(xml) { var titles = []; - jQuery('tab', xml).each(function() { - titles.push(jQuery(this).attr('title')); + jQuery("tab", xml).each(function() { + titles.push(jQuery(this).attr("title")); }); - equals( titles[0], 'Location', 'attr() in XML context: Check first title' ); - equals( titles[1], 'Users', 'attr() in XML context: Check second title' ); + equals( titles[0], "Location", "attr() in XML context: Check first title" ); + equals( titles[1], "Users", "attr() in XML context: Check second title" ); start(); }); }); @@ -343,64 +343,64 @@ test("attr('tabindex')", function() { expect(8); // elements not natively tabbable - equals(jQuery('#listWithTabIndex').attr('tabindex'), 5, 'not natively tabbable, with tabindex set to 0'); - equals(jQuery('#divWithNoTabIndex').attr('tabindex'), undefined, 'not natively tabbable, no tabindex set'); + equals(jQuery("#listWithTabIndex").attr("tabindex"), 5, "not natively tabbable, with tabindex set to 0"); + equals(jQuery("#divWithNoTabIndex").attr("tabindex"), undefined, "not natively tabbable, no tabindex set"); // anchor with href - equals(jQuery('#linkWithNoTabIndex').attr('tabindex'), 0, 'anchor with href, no tabindex set'); - equals(jQuery('#linkWithTabIndex').attr('tabindex'), 2, 'anchor with href, tabindex set to 2'); - equals(jQuery('#linkWithNegativeTabIndex').attr('tabindex'), -1, 'anchor with href, tabindex set to -1'); + equals(jQuery("#linkWithNoTabIndex").attr("tabindex"), 0, "anchor with href, no tabindex set"); + equals(jQuery("#linkWithTabIndex").attr("tabindex"), 2, "anchor with href, tabindex set to 2"); + equals(jQuery("#linkWithNegativeTabIndex").attr("tabindex"), -1, "anchor with href, tabindex set to -1"); // anchor without href - equals(jQuery('#linkWithNoHrefWithNoTabIndex').attr('tabindex'), undefined, 'anchor without href, no tabindex set'); - equals(jQuery('#linkWithNoHrefWithTabIndex').attr('tabindex'), 1, 'anchor without href, tabindex set to 2'); - equals(jQuery('#linkWithNoHrefWithNegativeTabIndex').attr('tabindex'), -1, 'anchor without href, no tabindex set'); + equals(jQuery("#linkWithNoHrefWithNoTabIndex").attr("tabindex"), undefined, "anchor without href, no tabindex set"); + equals(jQuery("#linkWithNoHrefWithTabIndex").attr("tabindex"), 1, "anchor without href, tabindex set to 2"); + equals(jQuery("#linkWithNoHrefWithNegativeTabIndex").attr("tabindex"), -1, "anchor without href, no tabindex set"); }); test("attr('tabindex', value)", function() { expect(9); - var element = jQuery('#divWithNoTabIndex'); - equals(element.attr('tabindex'), undefined, 'start with no tabindex'); + var element = jQuery("#divWithNoTabIndex"); + equals(element.attr("tabindex"), undefined, "start with no tabindex"); // set a positive string - element.attr('tabindex', '1'); - equals(element.attr('tabindex'), 1, 'set tabindex to 1 (string)'); + element.attr("tabindex", "1"); + equals(element.attr("tabindex"), 1, "set tabindex to 1 (string)"); // set a zero string - element.attr('tabindex', '0'); - equals(element.attr('tabindex'), 0, 'set tabindex to 0 (string)'); + element.attr("tabindex", "0"); + equals(element.attr("tabindex"), 0, "set tabindex to 0 (string)"); // set a negative string - element.attr('tabindex', '-1'); - equals(element.attr('tabindex'), -1, 'set tabindex to -1 (string)'); + element.attr("tabindex", "-1"); + equals(element.attr("tabindex"), -1, "set tabindex to -1 (string)"); // set a positive number - element.attr('tabindex', 1); - equals(element.attr('tabindex'), 1, 'set tabindex to 1 (number)'); + element.attr("tabindex", 1); + equals(element.attr("tabindex"), 1, "set tabindex to 1 (number)"); // set a zero number - element.attr('tabindex', 0); - equals(element.attr('tabindex'), 0, 'set tabindex to 0 (number)'); + element.attr("tabindex", 0); + equals(element.attr("tabindex"), 0, "set tabindex to 0 (number)"); // set a negative number - element.attr('tabindex', -1); - equals(element.attr('tabindex'), -1, 'set tabindex to -1 (number)'); + element.attr("tabindex", -1); + equals(element.attr("tabindex"), -1, "set tabindex to -1 (number)"); - element = jQuery('#linkWithTabIndex'); - equals(element.attr('tabindex'), 2, 'start with tabindex 2'); + element = jQuery("#linkWithTabIndex"); + equals(element.attr("tabindex"), 2, "start with tabindex 2"); - element.attr('tabindex', -1); - equals(element.attr('tabindex'), -1, 'set negative tabindex'); + element.attr("tabindex", -1); + equals(element.attr("tabindex"), -1, "set negative tabindex"); }); test("removeAttr(String)", function() { expect(5); - equals( jQuery('#mark').removeAttr( "class" )[0].className, "", "remove class" ); - equals( jQuery('#form').removeAttr('id').attr('id'), undefined, 'Remove id' ); - equals( jQuery('#foo').attr('style', 'position:absolute;').removeAttr('style').attr('style'), undefined, 'Check removing style attribute' ); - equals( jQuery('#form').attr('style', 'position:absolute;').removeAttr('style').attr('style'), undefined, 'Check removing style attribute on a form' ); - equals( jQuery('#fx-test-group').attr('height', '3px').removeAttr('height').css('height'), "1px", 'Removing height attribute has no effect on height set with style attribute' ); + equals( jQuery("#mark").removeAttr( "class" )[0].className, "", "remove class" ); + equals( jQuery("#form").removeAttr("id").attr("id"), undefined, "Remove id" ); + equals( jQuery("#foo").attr("style", "position:absolute;").removeAttr("style").attr("style"), undefined, "Check removing style attribute" ); + equals( jQuery("#form").attr("style", "position:absolute;").removeAttr("style").attr("style"), undefined, "Check removing style attribute on a form" ); + equals( jQuery("#fx-test-group").attr("height", "3px").removeAttr("height").css("height"), "1px", "Removing height attribute has no effect on height set with style attribute" ); }); test("removeProp(String)", function() { @@ -427,7 +427,7 @@ test("removeProp(String)", function() { test("val()", function() { expect(23); - document.getElementById('text1').value = "bla"; + document.getElementById("text1").value = "bla"; equals( jQuery("#text1").val(), "bla", "Check for modified value of input element" ); QUnit.reset(); @@ -437,36 +437,36 @@ test("val()", function() { equals( jQuery("#first").val(), "", "Check a paragraph element to see if it has a value" ); ok( jQuery([]).val() === undefined, "Check an empty jQuery object will return undefined from val" ); - equals( jQuery('#select2').val(), '3', 'Call val() on a single="single" select' ); + equals( jQuery("#select2").val(), "3", "Call val() on a single=\"single\" select" ); - same( jQuery('#select3').val(), ['1', '2'], 'Call val() on a multiple="multiple" select' ); + same( jQuery("#select3").val(), ["1", "2"], "Call val() on a multiple=\"multiple\" select" ); - equals( jQuery('#option3c').val(), '2', 'Call val() on a option element with value' ); + equals( jQuery("#option3c").val(), "2", "Call val() on a option element with value" ); - equals( jQuery('#option3a').val(), '', 'Call val() on a option element with empty value' ); + equals( jQuery("#option3a").val(), "", "Call val() on a option element with empty value" ); - equals( jQuery('#option3e').val(), 'no value', 'Call val() on a option element with no value attribute' ); + equals( jQuery("#option3e").val(), "no value", "Call val() on a option element with no value attribute" ); - equals( jQuery('#option3a').val(), '', 'Call val() on a option element with no value attribute' ); + equals( jQuery("#option3a").val(), "", "Call val() on a option element with no value attribute" ); - jQuery('#select3').val(""); - same( jQuery('#select3').val(), [''], 'Call val() on a multiple="multiple" select' ); + jQuery("#select3").val(""); + same( jQuery("#select3").val(), [""], "Call val() on a multiple=\"multiple\" select" ); - same( jQuery('#select4').val(), [], 'Call val() on multiple="multiple" select with all disabled options' ); + same( jQuery("#select4").val(), [], "Call val() on multiple=\"multiple\" select with all disabled options" ); - jQuery('#select4 optgroup').add('#select4 > [disabled]').attr('disabled', false); - same( jQuery('#select4').val(), ['2', '3'], 'Call val() on multiple="multiple" select with some disabled options' ); + jQuery("#select4 optgroup").add("#select4 > [disabled]").attr("disabled", false); + same( jQuery("#select4").val(), ["2", "3"], "Call val() on multiple=\"multiple\" select with some disabled options" ); - jQuery('#select4').attr('disabled', true); - same( jQuery('#select4').val(), ['2', '3'], 'Call val() on disabled multiple="multiple" select' ); + jQuery("#select4").attr("disabled", true); + same( jQuery("#select4").val(), ["2", "3"], "Call val() on disabled multiple=\"multiple\" select" ); - equals( jQuery('#select5').val(), "3", "Check value on ambiguous select." ); + equals( jQuery("#select5").val(), "3", "Check value on ambiguous select." ); - jQuery('#select5').val(1); - equals( jQuery('#select5').val(), "1", "Check value on ambiguous select." ); + jQuery("#select5").val(1); + equals( jQuery("#select5").val(), "1", "Check value on ambiguous select." ); - jQuery('#select5').val(3); - equals( jQuery('#select5').val(), "3", "Check value on ambiguous select." ); + jQuery("#select5").val(3); + equals( jQuery("#select5").val(), "3", "Check value on ambiguous select." ); var checks = jQuery("").appendTo("#form"); @@ -492,17 +492,17 @@ test("val()", function() { var testVal = function(valueObj) { expect(8); - jQuery("#text1").val(valueObj( 'test' )); - equals( document.getElementById('text1').value, "test", "Check for modified (via val(String)) value of input element" ); + jQuery("#text1").val(valueObj( "test" )); + equals( document.getElementById("text1").value, "test", "Check for modified (via val(String)) value of input element" ); jQuery("#text1").val(valueObj( undefined )); - equals( document.getElementById('text1').value, "", "Check for modified (via val(undefined)) value of input element" ); + equals( document.getElementById("text1").value, "", "Check for modified (via val(undefined)) value of input element" ); jQuery("#text1").val(valueObj( 67 )); - equals( document.getElementById('text1').value, "67", "Check for modified (via val(Number)) value of input element" ); + equals( document.getElementById("text1").value, "67", "Check for modified (via val(Number)) value of input element" ); jQuery("#text1").val(valueObj( null )); - equals( document.getElementById('text1').value, "", "Check for modified (via val(null)) value of input element" ); + equals( document.getElementById("text1").value, "", "Check for modified (via val(null)) value of input element" ); jQuery("#select1").val(valueObj( "3" )); equals( jQuery("#select1").val(), "3", "Check for modified (via val(String)) value of select element" ); @@ -531,8 +531,8 @@ test("val(Function)", function() { test( "val(Array of Numbers) (Bug #7123)", function() { expect(4); - jQuery('#form').append(''); - var elements = jQuery('input[name=arrayTest]').val([ 1, 2 ]); + jQuery("#form").append(""); + var elements = jQuery("input[name=arrayTest]").val([ 1, 2 ]); ok( elements[0].checked, "First element was checked" ); ok( elements[1].checked, "Second element was checked" ); ok( !elements[2].checked, "Third element was unchecked" ); @@ -551,7 +551,7 @@ test("val(Function) with incoming value", function() { return "test"; }); - equals( document.getElementById('text1').value, "test", "Check for modified (via val(String)) value of input element" ); + equals( document.getElementById("text1").value, "test", "Check for modified (via val(String)) value of input element" ); oldVal = jQuery("#text1").val(); @@ -560,7 +560,7 @@ test("val(Function) with incoming value", function() { return 67; }); - equals( document.getElementById('text1').value, "67", "Check for modified (via val(Number)) value of input element" ); + equals( document.getElementById("text1").value, "67", "Check for modified (via val(Number)) value of input element" ); oldVal = jQuery("#select1").val(); @@ -596,7 +596,7 @@ test("val(Function) with incoming value", function() { test("val(select) after form.reset() (Bug #2551)", function() { expect(3); - jQuery('
').appendTo("#main"); + jQuery("
").appendTo("#main"); jQuery("#kkk").val( "gf" ); @@ -606,7 +606,7 @@ test("val(select) after form.reset() (Bug #2551)", function() { equal( jQuery("#kkk").val(), "cf", "Check value of select after form reset." ); // re-verify the multi-select is not broken (after form.reset) by our fix for single-select - same( jQuery('#select3').val(), ['1', '2'], 'Call val() on a multiple="multiple" select' ); + same( jQuery("#select3").val(), ["1", "2"], "Call val() on a multiple=\"multiple\" select" ); jQuery("#kk").remove(); }); @@ -671,29 +671,29 @@ test("addClass(Function) with incoming value", function() { var testRemoveClass = function(valueObj) { expect(7); - var $divs = jQuery('div'); + var $divs = jQuery("div"); $divs.addClass("test").removeClass( valueObj("test") ); - ok( !$divs.is('.test'), "Remove Class" ); + ok( !$divs.is(".test"), "Remove Class" ); QUnit.reset(); - $divs = jQuery('div'); + $divs = jQuery("div"); $divs.addClass("test").addClass("foo").addClass("bar"); $divs.removeClass( valueObj("test") ).removeClass( valueObj("bar") ).removeClass( valueObj("foo") ); - ok( !$divs.is('.test,.bar,.foo'), "Remove multiple classes" ); + ok( !$divs.is(".test,.bar,.foo"), "Remove multiple classes" ); QUnit.reset(); - $divs = jQuery('div'); + $divs = jQuery("div"); // Make sure that a null value doesn't cause problems $divs.eq(0).addClass("test").removeClass( valueObj(null) ); - ok( $divs.eq(0).is('.test'), "Null value passed to removeClass" ); + ok( $divs.eq(0).is(".test"), "Null value passed to removeClass" ); $divs.eq(0).addClass("test").removeClass( valueObj("") ); - ok( $divs.eq(0).is('.test'), "Empty string passed to removeClass" ); + ok( $divs.eq(0).is(".test"), "Empty string passed to removeClass" ); // using contents will get regular, text, and comment nodes var j = jQuery("#nonnodes").contents(); @@ -723,7 +723,7 @@ test("removeClass(Function) - simple", function() { test("removeClass(Function) with incoming value", function() { expect(45); - var $divs = jQuery('div').addClass("test"), old = $divs.map(function(){ + var $divs = jQuery("div").addClass("test"), old = $divs.map(function(){ return jQuery(this).attr("class"); }); @@ -734,7 +734,7 @@ test("removeClass(Function) with incoming value", function() { } }); - ok( !$divs.is('.test'), "Remove Class" ); + ok( !$divs.is(".test"), "Remove Class" ); QUnit.reset(); }); @@ -772,7 +772,7 @@ var testToggleClass = function(valueObj) { ok( e.is(".testD.testE"), "Assert class present" ); e.toggleClass(); ok( !e.is(".testD.testE"), "Assert class not present" ); - ok( jQuery._data(e[0], '__className__') === 'testD testE', "Assert data was stored" ); + ok( jQuery._data(e[0], "__className__") === "testD testE", "Assert data was stored" ); e.toggleClass(); ok( e.is(".testD.testE"), "Assert class present (restored from data)" ); e.toggleClass(false); @@ -786,7 +786,7 @@ var testToggleClass = function(valueObj) { // Cleanup e.removeClass("testD"); - jQuery.removeData(e[0], '__className__', true); + jQuery.removeData(e[0], "__className__", true); }; test("toggleClass(String|boolean|undefined[, boolean])", function() { @@ -847,7 +847,7 @@ test("toggleClass(Fucntion[, boolean]) with incoming value", function() { // Cleanup e.removeClass("test"); - jQuery.removeData(e[0], '__className__', true); + jQuery.removeData(e[0], "__className__", true); }); test("addClass, removeClass, hasClass", function() { diff --git a/test/unit/core.js b/test/unit/core.js index c2a23b1a8..bb02a0aa6 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -62,7 +62,7 @@ test("jQuery()", function() { equals( jQuery([1,2,3]).get(1), 2, "Test passing an array to the factory" ); - equals( jQuery(document.body).get(0), jQuery('body').get(0), "Test passing an html node to the factory" ); + equals( jQuery(document.body).get(0), jQuery("body").get(0), "Test passing an html node to the factory" ); var exec = false; @@ -75,13 +75,13 @@ test("jQuery()", function() { id: "test3" }); - equals( elem[0].style.width, '10px', 'jQuery() quick setter width'); - equals( elem[0].style.paddingLeft, '1px', 'jQuery quick setter css'); - equals( elem[0].style.paddingRight, '1px', 'jQuery quick setter css'); - equals( elem[0].childNodes.length, 1, 'jQuery quick setter text'); - equals( elem[0].firstChild.nodeValue, "test", 'jQuery quick setter text'); - equals( elem[0].className, "test2", 'jQuery() quick setter class'); - equals( elem[0].id, "test3", 'jQuery() quick setter id'); + equals( elem[0].style.width, "10px", "jQuery() quick setter width"); + equals( elem[0].style.paddingLeft, "1px", "jQuery quick setter css"); + equals( elem[0].style.paddingRight, "1px", "jQuery quick setter css"); + equals( elem[0].childNodes.length, 1, "jQuery quick setter text"); + equals( elem[0].firstChild.nodeValue, "test", "jQuery quick setter text"); + equals( elem[0].className, "test2", "jQuery() quick setter class"); + equals( elem[0].id, "test3", "jQuery() quick setter id"); exec = true; elem.click(); @@ -460,7 +460,7 @@ if ( !isLocal ) { test("isXMLDoc - XML", function() { expect(3); stop(); - jQuery.get('data/dashboard.xml', function(xml) { + jQuery.get("data/dashboard.xml", function(xml) { ok( jQuery.isXMLDoc( xml ), "XML document" ); ok( jQuery.isXMLDoc( xml.documentElement ), "XML documentElement" ); ok( jQuery.isXMLDoc( jQuery("tab", xml)[0] ), "XML Tab Element" ); @@ -524,15 +524,15 @@ test("jQuery('html')", function() { // Test very large html string #7990 var i; - var li = '
  • very large html string
  • '; - var html = ['
      ']; + var li = "
    • very large html string
    • "; + var html = ["
        "]; for ( i = 0; i < 50000; i += 1 ) { html.push(li); } - html.push('
      '); - html = jQuery(html.join(''))[0]; - equals( html.nodeName.toUpperCase(), 'UL'); - equals( html.firstChild.nodeName.toUpperCase(), 'LI'); + html.push("
    "); + html = jQuery(html.join(""))[0]; + equals( html.nodeName.toUpperCase(), "UL"); + equals( html.firstChild.nodeName.toUpperCase(), "LI"); equals( html.childNodes.length, 50000 ); }); @@ -548,7 +548,7 @@ if ( !isLocal ) { test("jQuery(selector, xml).text(str) - Loaded via XML document", function() { expect(2); stop(); - jQuery.get('data/dashboard.xml', function(xml) { + jQuery.get("data/dashboard.xml", function(xml) { // tests for #1419 where IE was a problem var tab = jQuery("tab", xml).eq(0); equals( tab.text(), "blabla", "Verify initial text correct" ); @@ -561,12 +561,12 @@ test("jQuery(selector, xml).text(str) - Loaded via XML document", function() { test("end()", function() { expect(3); - equals( 'Yahoo', jQuery('#yahoo').parent().end().text(), 'Check for end' ); - ok( jQuery('#yahoo').end(), 'Check for end with nothing to end' ); + equals( "Yahoo", jQuery("#yahoo").parent().end().text(), "Check for end" ); + ok( jQuery("#yahoo").end(), "Check for end with nothing to end" ); - var x = jQuery('#yahoo'); + var x = jQuery("#yahoo"); x.parent(); - equals( 'Yahoo', jQuery('#yahoo').text(), 'Check for non-destructive behaviour' ); + equals( "Yahoo", jQuery("#yahoo").text(), "Check for non-destructive behaviour" ); }); test("length", function() { @@ -606,7 +606,7 @@ test("get(-Number)",function() { test("each(Function)", function() { expect(1); var div = jQuery("div"); - div.each(function(){this.foo = 'zoo';}); + div.each(function(){this.foo = "zoo";}); var pass = true; for ( var i = 0; i < div.size(); i++ ) { if ( div.get(i).foo != "zoo" ) pass = false; @@ -625,7 +625,7 @@ test("slice()", function() { same( $links.slice(-1).get(), q("mark"), "slice(-1)" ); same( $links.eq(1).get(), q("groups"), "eq(1)" ); - same( $links.eq('2').get(), q("anchor1"), "eq('2')" ); + same( $links.eq("2").get(), q("anchor1"), "eq('2')" ); same( $links.eq(-1).get(), q("mark"), "eq(-1)" ); }); @@ -792,7 +792,7 @@ test("jQuery.extend(Object, Object)", function() { ok( typeof ret.foo != "string", "Check to make sure values equal with coersion (but not actually equal) overwrite correctly" ); var ret = jQuery.extend(true, { foo:"bar" }, { foo:null } ); - ok( typeof ret.foo !== 'undefined', "Make sure a null value doesn't crash with deep extend, for #1908" ); + ok( typeof ret.foo !== "undefined", "Make sure a null value doesn't crash with deep extend, for #1908" ); var obj = { foo:null }; jQuery.extend(true, obj, { foo:"notnull" } ); @@ -845,9 +845,9 @@ test("jQuery.each(Object,Function)", function() { equals( total, 3, "Looping over an object, with break" ); var f = function(){}; - f.foo = 'bar'; + f.foo = "bar"; jQuery.each(f, function(i){ - f[i] = 'baz'; + f[i] = "baz"; }); equals( "baz", f.foo, "Loop over a function" ); }); @@ -855,7 +855,7 @@ test("jQuery.each(Object,Function)", function() { test("jQuery.makeArray", function(){ expect(17); - equals( jQuery.makeArray(jQuery('html>*'))[0].nodeName.toUpperCase(), "HEAD", "Pass makeArray a jQuery object" ); + equals( jQuery.makeArray(jQuery("html>*"))[0].nodeName.toUpperCase(), "HEAD", "Pass makeArray a jQuery object" ); equals( jQuery.makeArray(document.getElementsByName("PWD")).slice(0,1)[0].name, "PWD", "Pass makeArray a nodelist" ); @@ -885,11 +885,11 @@ test("jQuery.makeArray", function(){ equals( jQuery.makeArray(/a/)[0].constructor, RegExp, "Pass makeArray a regex" ); - ok( jQuery.makeArray(document.getElementById('form')).length >= 13, "Pass makeArray a form (treat as elements)" ); + ok( jQuery.makeArray(document.getElementById("form")).length >= 13, "Pass makeArray a form (treat as elements)" ); // For #5610 - same( jQuery.makeArray({'length': '0'}), [], "Make sure object is coerced properly."); - same( jQuery.makeArray({'length': '5'}), [], "Make sure object is coerced properly."); + same( jQuery.makeArray({length: "0"}), [], "Make sure object is coerced properly."); + same( jQuery.makeArray({length: "5"}), [], "Make sure object is coerced properly."); }); test("jQuery.isEmptyObject", function(){ @@ -938,9 +938,9 @@ test("jQuery.parseJSON", function(){ equals( jQuery.parseJSON( "" ), null, "Nothing in, null out." ); same( jQuery.parseJSON("{}"), {}, "Plain object parsing." ); - same( jQuery.parseJSON('{"test":1}'), {"test":1}, "Plain object parsing." ); + same( jQuery.parseJSON("{\"test\":1}"), {"test":1}, "Plain object parsing." ); - same( jQuery.parseJSON('\n{"test":1}'), {"test":1}, "Make sure leading whitespaces are handled." ); + same( jQuery.parseJSON("\n{\"test\":1}"), {"test":1}, "Make sure leading whitespaces are handled." ); try { jQuery.parseJSON("{a:1}"); @@ -964,7 +964,7 @@ test("jQuery.sub() - Static Methods", function(){ topLevelMethod: function() {return this.debug;}, debug: false, config: { - locale: 'en_US' + locale: "en_US" }, setup: function(config) { this.extend(true, this.config, config); @@ -973,37 +973,37 @@ test("jQuery.sub() - Static Methods", function(){ Subclass.fn.extend({subClassMethod: function() { return this;}}); //Test Simple Subclass - ok(Subclass.topLevelMethod() === false, 'Subclass.topLevelMethod thought debug was true'); - ok(Subclass.config.locale == 'en_US', Subclass.config.locale + ' is wrong!'); - same(Subclass.config.test, undefined, 'Subclass.config.test is set incorrectly'); - equal(jQuery.ajax, Subclass.ajax, 'The subclass failed to get all top level methods'); + ok(Subclass.topLevelMethod() === false, "Subclass.topLevelMethod thought debug was true"); + ok(Subclass.config.locale == "en_US", Subclass.config.locale + " is wrong!"); + same(Subclass.config.test, undefined, "Subclass.config.test is set incorrectly"); + equal(jQuery.ajax, Subclass.ajax, "The subclass failed to get all top level methods"); //Create a SubSubclass var SubSubclass = Subclass.sub(); //Make Sure the SubSubclass inherited properly - ok(SubSubclass.topLevelMethod() === false, 'SubSubclass.topLevelMethod thought debug was true'); - ok(SubSubclass.config.locale == 'en_US', SubSubclass.config.locale + ' is wrong!'); - same(SubSubclass.config.test, undefined, 'SubSubclass.config.test is set incorrectly'); - equal(jQuery.ajax, SubSubclass.ajax, 'The subsubclass failed to get all top level methods'); + ok(SubSubclass.topLevelMethod() === false, "SubSubclass.topLevelMethod thought debug was true"); + ok(SubSubclass.config.locale == "en_US", SubSubclass.config.locale + " is wrong!"); + same(SubSubclass.config.test, undefined, "SubSubclass.config.test is set incorrectly"); + equal(jQuery.ajax, SubSubclass.ajax, "The subsubclass failed to get all top level methods"); //Modify The Subclass and test the Modifications SubSubclass.fn.extend({subSubClassMethod: function() { return this;}}); - SubSubclass.setup({locale: 'es_MX', test: 'worked'}); + SubSubclass.setup({locale: "es_MX", test: "worked"}); SubSubclass.debug = true; SubSubclass.ajax = function() {return false;}; - ok(SubSubclass.topLevelMethod(), 'SubSubclass.topLevelMethod thought debug was false'); - same(SubSubclass(document).subClassMethod, Subclass.fn.subClassMethod, 'Methods Differ!'); - ok(SubSubclass.config.locale == 'es_MX', SubSubclass.config.locale + ' is wrong!'); - ok(SubSubclass.config.test == 'worked', 'SubSubclass.config.test is set incorrectly'); - notEqual(jQuery.ajax, SubSubclass.ajax, 'The subsubclass failed to get all top level methods'); + ok(SubSubclass.topLevelMethod(), "SubSubclass.topLevelMethod thought debug was false"); + same(SubSubclass(document).subClassMethod, Subclass.fn.subClassMethod, "Methods Differ!"); + ok(SubSubclass.config.locale == "es_MX", SubSubclass.config.locale + " is wrong!"); + ok(SubSubclass.config.test == "worked", "SubSubclass.config.test is set incorrectly"); + notEqual(jQuery.ajax, SubSubclass.ajax, "The subsubclass failed to get all top level methods"); //This shows that the modifications to the SubSubClass did not bubble back up to it's superclass - ok(Subclass.topLevelMethod() === false, 'Subclass.topLevelMethod thought debug was true'); - ok(Subclass.config.locale == 'en_US', Subclass.config.locale + ' is wrong!'); - same(Subclass.config.test, undefined, 'Subclass.config.test is set incorrectly'); - same(Subclass(document).subSubClassMethod, undefined, 'subSubClassMethod set incorrectly'); - equal(jQuery.ajax, Subclass.ajax, 'The subclass failed to get all top level methods'); + ok(Subclass.topLevelMethod() === false, "Subclass.topLevelMethod thought debug was true"); + ok(Subclass.config.locale == "en_US", Subclass.config.locale + " is wrong!"); + same(Subclass.config.test, undefined, "Subclass.config.test is set incorrectly"); + same(Subclass(document).subSubClassMethod, undefined, "subSubClassMethod set incorrectly"); + equal(jQuery.ajax, Subclass.ajax, "The subclass failed to get all top level methods"); }); test("jQuery.sub() - .fn Methods", function(){ @@ -1014,25 +1014,25 @@ test("jQuery.sub() - .fn Methods", function(){ jQueryDocument = jQuery(document), selectors, contexts, methods, method, arg, description; - jQueryDocument.toString = function(){ return 'jQueryDocument'; }; + jQueryDocument.toString = function(){ return "jQueryDocument"; }; Subclass.fn.subclassMethod = function(){}; SubclassSubclass.fn.subclassSubclassMethod = function(){}; selectors = [ - 'body', - 'html, body', - '
    ' + "body", + "html, body", + "
    " ]; methods = [ // all methods that return a new jQuery instance - ['eq', 1], - ['add', document], - ['end'], - ['has'], - ['closest', 'div'], - ['filter', document], - ['find', 'div'] + ["eq", 1], + ["add", document], + ["end"], + ["has"], + ["closest", "div"], + ["filter", document], + ["find", "div"] ]; contexts = [undefined, document, jQueryDocument]; @@ -1045,31 +1045,31 @@ test("jQuery.sub() - .fn Methods", function(){ jQuery.each(contexts, function(i, context){ - description = '("'+selector+'", '+context+').'+method+'('+(arg||'')+')'; + description = "(\""+selector+"\", "+context+")."+method+"("+(arg||"")+")"; same( jQuery(selector, context)[method](arg).subclassMethod, undefined, - 'jQuery'+description+' doesnt have Subclass methods' + "jQuery"+description+" doesn't have Subclass methods" ); same( jQuery(selector, context)[method](arg).subclassSubclassMethod, undefined, - 'jQuery'+description+' doesnt have SubclassSubclass methods' + "jQuery"+description+" doesn't have SubclassSubclass methods" ); same( Subclass(selector, context)[method](arg).subclassMethod, Subclass.fn.subclassMethod, - 'Subclass'+description+' has Subclass methods' + "Subclass"+description+" has Subclass methods" ); same( Subclass(selector, context)[method](arg).subclassSubclassMethod, undefined, - 'Subclass'+description+' doesnt have SubclassSubclass methods' + "Subclass"+description+" doesn't have SubclassSubclass methods" ); same( SubclassSubclass(selector, context)[method](arg).subclassMethod, Subclass.fn.subclassMethod, - 'SubclassSubclass'+description+' has Subclass methods' + "SubclassSubclass"+description+" has Subclass methods" ); same( SubclassSubclass(selector, context)[method](arg).subclassSubclassMethod, SubclassSubclass.fn.subclassSubclassMethod, - 'SubclassSubclass'+description+' has SubclassSubclass methods' + "SubclassSubclass"+description+" has SubclassSubclass methods" ); }); diff --git a/test/unit/css.js b/test/unit/css.js index 08f50ef25..3996fbccf 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -3,13 +3,13 @@ module("css", { teardown: moduleTeardown }); test("css(String|Hash)", function() { expect(41); - equals( jQuery('#main').css("display"), 'block', 'Check for css property "display"'); + equals( jQuery("#main").css("display"), "block", "Check for css property \"display\""); - ok( jQuery('#nothiddendiv').is(':visible'), 'Modifying CSS display: Assert element is visible'); - jQuery('#nothiddendiv').css({display: 'none'}); - ok( !jQuery('#nothiddendiv').is(':visible'), 'Modified CSS display: Assert element is hidden'); - jQuery('#nothiddendiv').css({display: 'block'}); - ok( jQuery('#nothiddendiv').is(':visible'), 'Modified CSS display: Assert element is visible'); + ok( jQuery("#nothiddendiv").is(":visible"), "Modifying CSS display: Assert element is visible"); + jQuery("#nothiddendiv").css({display: "none"}); + ok( !jQuery("#nothiddendiv").is(":visible"), "Modified CSS display: Assert element is hidden"); + jQuery("#nothiddendiv").css({display: "block"}); + ok( jQuery("#nothiddendiv").is(":visible"), "Modified CSS display: Assert element is visible"); var div = jQuery( "
    " ); @@ -32,34 +32,34 @@ test("css(String|Hash)", function() { div2.remove(); // handle negative numbers by ignoring #1599, #4216 - jQuery('#nothiddendiv').css({ 'width': 1, 'height': 1 }); + jQuery("#nothiddendiv").css( {width: 1, height: 1} ); - var width = parseFloat(jQuery('#nothiddendiv').css('width')), height = parseFloat(jQuery('#nothiddendiv').css('height')); - jQuery('#nothiddendiv').css({ width: -1, height: -1 }); - equals( parseFloat(jQuery('#nothiddendiv').css('width')), width, 'Test negative width ignored') - equals( parseFloat(jQuery('#nothiddendiv').css('height')), height, 'Test negative height ignored') + var width = parseFloat(jQuery("#nothiddendiv").css("width")), height = parseFloat(jQuery("#nothiddendiv").css("height")); + jQuery("#nothiddendiv").css({ width: -1, height: -1 }); + equals( parseFloat(jQuery("#nothiddendiv").css("width")), width, "Test negative width ignored") + equals( parseFloat(jQuery("#nothiddendiv").css("height")), height, "Test negative height ignored") - equals( jQuery('
    ').css('display'), 'none', 'Styles on disconnected nodes'); + equals( jQuery("
    ").css("display"), "none", "Styles on disconnected nodes"); - jQuery('#floatTest').css({'float': 'right'}); - equals( jQuery('#floatTest').css('float'), 'right', 'Modified CSS float using "float": Assert float is right'); - jQuery('#floatTest').css({'font-size': '30px'}); - equals( jQuery('#floatTest').css('font-size'), '30px', 'Modified CSS font-size: Assert font-size is 30px'); + jQuery("#floatTest").css({"float": "right"}); + equals( jQuery("#floatTest").css("float"), "right", "Modified CSS float using \"float\": Assert float is right"); + jQuery("#floatTest").css({"font-size": "30px"}); + equals( jQuery("#floatTest").css("font-size"), "30px", "Modified CSS font-size: Assert font-size is 30px"); - jQuery.each("0,0.25,0.5,0.75,1".split(','), function(i, n) { - jQuery('#foo').css({opacity: n}); - equals( jQuery('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" ); - jQuery('#foo').css({opacity: parseFloat(n)}); - equals( jQuery('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" ); + jQuery.each("0,0.25,0.5,0.75,1".split(","), function(i, n) { + jQuery("#foo").css({opacity: n}); + equals( jQuery("#foo").css("opacity"), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" ); + jQuery("#foo").css({opacity: parseFloat(n)}); + equals( jQuery("#foo").css("opacity"), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" ); }); - jQuery('#foo').css({opacity: ''}); - equals( jQuery('#foo').css('opacity'), '1', "Assert opacity is 1 when set to an empty String" ); + jQuery("#foo").css({opacity: ""}); + equals( jQuery("#foo").css("opacity"), "1", "Assert opacity is 1 when set to an empty String" ); - equals( jQuery('#empty').css('opacity'), '0', "Assert opacity is accessible via filter property set in stylesheet in IE" ); - jQuery('#empty').css({ opacity: '1' }); - equals( jQuery('#empty').css('opacity'), '1', "Assert opacity is taken from style attribute when set vs stylesheet in IE with filters" ); + equals( jQuery("#empty").css("opacity"), "0", "Assert opacity is accessible via filter property set in stylesheet in IE" ); + jQuery("#empty").css({ opacity: "1" }); + equals( jQuery("#empty").css("opacity"), "1", "Assert opacity is taken from style attribute when set vs stylesheet in IE with filters" ); - var div = jQuery('#nothiddendiv'), child = jQuery('#nothiddendivchild'); + var div = jQuery("#nothiddendiv"), child = jQuery("#nothiddendivchild"); equals( parseInt(div.css("fontSize")), 16, "Verify fontSize px set." ); equals( parseInt(div.css("font-size")), 16, "Verify fontSize px set." ); @@ -107,7 +107,7 @@ test("css(String|Hash)", function() { test("css() explicit and relative values", function() { expect(9); - var $elem = jQuery('#nothiddendiv'); + var $elem = jQuery("#nothiddendiv"); $elem.css({ width: 1, height: 1 }); equals( $elem.width(), 1, "Initial css set or width/height works (hash)" ); @@ -140,28 +140,28 @@ test("css() explicit and relative values", function() { test("css(String, Object)", function() { expect(22); - ok( jQuery('#nothiddendiv').is(':visible'), 'Modifying CSS display: Assert element is visible'); - jQuery('#nothiddendiv').css("display", 'none'); - ok( !jQuery('#nothiddendiv').is(':visible'), 'Modified CSS display: Assert element is hidden'); - jQuery('#nothiddendiv').css("display", 'block'); - ok( jQuery('#nothiddendiv').is(':visible'), 'Modified CSS display: Assert element is visible'); + ok( jQuery("#nothiddendiv").is(":visible"), "Modifying CSS display: Assert element is visible"); + jQuery("#nothiddendiv").css("display", "none"); + ok( !jQuery("#nothiddendiv").is(":visible"), "Modified CSS display: Assert element is hidden"); + jQuery("#nothiddendiv").css("display", "block"); + ok( jQuery("#nothiddendiv").is(":visible"), "Modified CSS display: Assert element is visible"); jQuery("#nothiddendiv").css("top", "-1em"); ok( jQuery("#nothiddendiv").css("top"), -16, "Check negative number in EMs." ); - jQuery('#floatTest').css('float', 'left'); - equals( jQuery('#floatTest').css('float'), 'left', 'Modified CSS float using "float": Assert float is left'); - jQuery('#floatTest').css('font-size', '20px'); - equals( jQuery('#floatTest').css('font-size'), '20px', 'Modified CSS font-size: Assert font-size is 20px'); + jQuery("#floatTest").css("float", "left"); + equals( jQuery("#floatTest").css("float"), "left", "Modified CSS float using \"float\": Assert float is left"); + jQuery("#floatTest").css("font-size", "20px"); + equals( jQuery("#floatTest").css("font-size"), "20px", "Modified CSS font-size: Assert font-size is 20px"); - jQuery.each("0,0.25,0.5,0.75,1".split(','), function(i, n) { - jQuery('#foo').css('opacity', n); - equals( jQuery('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" ); - jQuery('#foo').css('opacity', parseFloat(n)); - equals( jQuery('#foo').css('opacity'), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" ); + jQuery.each("0,0.25,0.5,0.75,1".split(","), function(i, n) { + jQuery("#foo").css("opacity", n); + equals( jQuery("#foo").css("opacity"), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" ); + jQuery("#foo").css("opacity", parseFloat(n)); + equals( jQuery("#foo").css("opacity"), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" ); }); - jQuery('#foo').css('opacity', ''); - equals( jQuery('#foo').css('opacity'), '1', "Assert opacity is 1 when set to an empty String" ); + jQuery("#foo").css("opacity", ""); + equals( jQuery("#foo").css("opacity"), "1", "Assert opacity is 1 when set to an empty String" ); // using contents will get comments regular, text, and comment nodes var j = jQuery("#nonnodes").contents(); @@ -181,7 +181,7 @@ test("css(String, Object)", function() { // Test for Bug #5509 var success = true; try { - jQuery('#foo').css("backgroundColor", "rgba(0, 0, 0, 0.1)"); + jQuery("#foo").css("backgroundColor", "rgba(0, 0, 0, 0.1)"); } catch (e) { success = false; @@ -192,19 +192,19 @@ test("css(String, Object)", function() { if ( !jQuery.support.opacity ) { test("css(String, Object) for MSIE", function() { // for #1438, IE throws JS error when filter exists but doesn't have opacity in it - jQuery('#foo').css("filter", "progid:DXImageTransform.Microsoft.Chroma(color='red');"); - equals( jQuery('#foo').css('opacity'), '1', "Assert opacity is 1 when a different filter is set in IE, #1438" ); + jQuery("#foo").css("filter", "progid:DXImageTransform.Microsoft.Chroma(color='red');"); + equals( jQuery("#foo").css("opacity"), "1", "Assert opacity is 1 when a different filter is set in IE, #1438" ); var filterVal = "progid:DXImageTransform.Microsoft.Alpha(opacity=30) progid:DXImageTransform.Microsoft.Blur(pixelradius=5)"; var filterVal2 = "progid:DXImageTransform.Microsoft.alpha(opacity=100) progid:DXImageTransform.Microsoft.Blur(pixelradius=5)"; var filterVal3 = "progid:DXImageTransform.Microsoft.Blur(pixelradius=5)"; - jQuery('#foo').css("filter", filterVal); - equals( jQuery('#foo').css("filter"), filterVal, "css('filter', val) works" ); - jQuery('#foo').css("opacity", 1); - equals( jQuery('#foo').css("filter"), filterVal2, "Setting opacity in IE doesn't duplicate opacity filter" ); - equals( jQuery('#foo').css("opacity"), 1, "Setting opacity in IE with other filters works" ); - jQuery('#foo').css("filter", filterVal3).css("opacity", 1); - ok( jQuery('#foo').css("filter").indexOf(filterVal3) !== -1, "Setting opacity in IE doesn't clobber other filters" ); + jQuery("#foo").css("filter", filterVal); + equals( jQuery("#foo").css("filter"), filterVal, "css('filter', val) works" ); + jQuery("#foo").css("opacity", 1); + equals( jQuery("#foo").css("filter"), filterVal2, "Setting opacity in IE doesn't duplicate opacity filter" ); + equals( jQuery("#foo").css("opacity"), 1, "Setting opacity in IE with other filters works" ); + jQuery("#foo").css("filter", filterVal3).css("opacity", 1); + ok( jQuery("#foo").css("filter").indexOf(filterVal3) !== -1, "Setting opacity in IE doesn't clobber other filters" ); }); } @@ -343,14 +343,14 @@ test("jQuery.css(elem, 'height') doesn't clear radio buttons (bug #1095)", funct test(":visible selector works properly on table elements (bug #4512)", function () { expect(1); - jQuery('#table').html('cellcell'); - equals(jQuery('#table td:visible').length, 1, "hidden cell is not perceived as visible"); + jQuery("#table").html("cellcell"); + equals(jQuery("#table td:visible").length, 1, "hidden cell is not perceived as visible"); }); test(":visible selector works properly on children with a hidden parent (bug #4512)", function () { expect(1); - jQuery('#table').css('display', 'none').html('cellcell'); - equals(jQuery('#table td:visible').length, 0, "hidden cell children not perceived as visible"); + jQuery("#table").css("display", "none").html("cellcell"); + equals(jQuery("#table td:visible").length, 0, "hidden cell children not perceived as visible"); }); test("internal ref to elem.runtimeStyle (bug #7608)", function () { diff --git a/test/unit/data.js b/test/unit/data.js index 94fa2a018..888f71cbf 100644 --- a/test/unit/data.js +++ b/test/unit/data.js @@ -283,11 +283,11 @@ test(".data(String) and .data(String, Object)", function() { // #3748 var $elem = jQuery({exists:true}); - equals( $elem.data('nothing'), undefined, "Non-existent data returns undefined"); - equals( $elem.data('null',null).data('null'), null, "null's are preserved"); - equals( $elem.data('emptyString','').data('emptyString'), '', "Empty strings are preserved"); - equals( $elem.data('false',false).data('false'), false, "false's are preserved"); - equals( $elem.data('exists'), undefined, "Existing data is not returned" ); + equals( $elem.data("nothing"), undefined, "Non-existent data returns undefined"); + equals( $elem.data("null", null).data("null"), null, "null's are preserved"); + equals( $elem.data("emptyString", "").data("emptyString"), "", "Empty strings are preserved"); + equals( $elem.data("false", false).data("false"), false, "false's are preserved"); + equals( $elem.data("exists"), undefined, "Existing data is not returned" ); // Clean up $elem.removeData(); @@ -316,7 +316,7 @@ test("data-* attributes", function() { div.remove(); - child.appendTo('#main'); + child.appendTo("#main"); equals( child.data("myobj"), "old data", "Value accessed from data-* attribute"); child.data("myobj", "replaced"); @@ -365,19 +365,19 @@ test("data-* attributes", function() { .attr("data-null", "null") .attr("data-string", "test"); - strictEqual( child.data('true'), true, "Primitive true read from attribute"); - strictEqual( child.data('false'), false, "Primitive false read from attribute"); - strictEqual( child.data('five'), 5, "Primitive number read from attribute"); - strictEqual( child.data('point'), 5.5, "Primitive number read from attribute"); - strictEqual( child.data('pointe'), 5500, "Primitive number read from attribute"); - strictEqual( child.data('pointbad'), "5..5", "Bad number read from attribute"); - strictEqual( child.data('pointbad2'), "-.", "Bad number read from attribute"); - strictEqual( child.data('badjson'), "{123}", "Bad number read from attribute"); - strictEqual( child.data('badjson2'), "[abc]", "Bad number read from attribute"); - strictEqual( child.data('empty'), "", "Empty string read from attribute"); - strictEqual( child.data('space'), " ", "Empty string read from attribute"); - strictEqual( child.data('null'), null, "Primitive null read from attribute"); - strictEqual( child.data('string'), "test", "Typical string read from attribute"); + strictEqual( child.data("true"), true, "Primitive true read from attribute"); + strictEqual( child.data("false"), false, "Primitive false read from attribute"); + strictEqual( child.data("five"), 5, "Primitive number read from attribute"); + strictEqual( child.data("point"), 5.5, "Primitive number read from attribute"); + strictEqual( child.data("pointe"), 5500, "Primitive number read from attribute"); + strictEqual( child.data("pointbad"), "5..5", "Bad number read from attribute"); + strictEqual( child.data("pointbad2"), "-.", "Bad number read from attribute"); + strictEqual( child.data("badjson"), "{123}", "Bad number read from attribute"); + strictEqual( child.data("badjson2"), "[abc]", "Bad number read from attribute"); + strictEqual( child.data("empty"), "", "Empty string read from attribute"); + strictEqual( child.data("space"), " ", "Empty string read from attribute"); + strictEqual( child.data("null"), null, "Primitive null read from attribute"); + strictEqual( child.data("string"), "test", "Typical string read from attribute"); child.remove(); @@ -401,12 +401,12 @@ test("data-* attributes", function() { same(jQuery(elem).data("stuff"), [2,8], "Check stuff property"); break; default: - ok(false, ["Assertion failed on index ", index, ", with data ", data].join('')); + ok(false, ["Assertion failed on index ", index, ", with data ", data].join("")); } } - var metadata = '
    1. Some stuff
    2. Some stuff
    3. Some stuff
    4. Some stuff
    ', - elem = jQuery(metadata).appendTo('#main'); + var metadata = "
    1. Some stuff
    2. Some stuff
    3. Some stuff
    4. Some stuff
    ", + elem = jQuery(metadata).appendTo("#main"); elem.find("li").each(testData); elem.remove(); @@ -483,7 +483,7 @@ if (window.JSON && window.JSON.stringify) { var obj = { foo: "bar" }; jQuery.data(obj, "hidden", true); - equals( JSON.stringify(obj), '{"foo":"bar"}', "Expando is hidden from JSON.stringify" ); + equals( JSON.stringify(obj), "{\"foo\":\"bar\"}", "Expando is hidden from JSON.stringify" ); }); } -- cgit v1.2.3 From 2b70893928035d53f46575003197e4a1fa52a844 Mon Sep 17 00:00:00 2001 From: jaubourg Date: Tue, 12 Apr 2011 01:09:35 +0200 Subject: Bug fixes in queue.js: type in dequeue could be undefined which lead to a wrong data key, which would then have undesirable data left dangling on elements. Also adds missing semicolon in effects unit. --- src/queue.js | 19 +++++++------------ test/unit/effects.js | 2 +- 2 files changed, 8 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/queue.js b/src/queue.js index ab06ae924..ce2305426 100644 --- a/src/queue.js +++ b/src/queue.js @@ -7,7 +7,7 @@ function handleQueueMarkDefer( elem, type, src ) { defer = jQuery.data( elem, deferDataKey, undefined, true ); if ( defer && ( src === "queue" || !jQuery.data( elem, queueDataKey, undefined, true ) ) && - ( src === "mark " || !jQuery.data( elem, markDataKey, undefined, true ) ) ) { + ( src === "mark" || !jQuery.data( elem, markDataKey, undefined, true ) ) ) { // Give room for hard-coded callbacks to fire first // and eventually mark/queue something else on the element setTimeout( function() { @@ -35,13 +35,10 @@ jQuery.extend({ elem = force; force = false; } - if ( elem ) { type = type || "fx"; - var key = type + "mark", count = force ? 0 : ( (jQuery.data( elem, key, undefined, true) || 1 ) - 1 ); - if ( count ) { jQuery.data( elem, key, count, true ); } else { @@ -54,21 +51,22 @@ jQuery.extend({ queue: function( elem, type, data ) { if ( elem ) { type = (type || "fx") + "queue"; - var q = jQuery.data( elem, type, undefined, true ) || []; - + var q = jQuery.data( elem, type, undefined, true ); // Speed up dequeue by getting out quickly if this is just a lookup if ( data ) { - if ( !q.length || jQuery.isArray(data) ) { + if ( !q || jQuery.isArray(data) ) { q = jQuery.data( elem, type, jQuery.makeArray(data), true ); } else { q.push( data ); } } - return q; + return q || []; } }, dequeue: function( elem, type ) { + type = type || "fx"; + var queue = jQuery.queue( elem, type ), fn = queue.shift(), defer; @@ -107,7 +105,7 @@ jQuery.fn.extend({ if ( data === undefined ) { return jQuery.queue( this[0], type ); } - return this.each(function( i ) { + return this.each(function() { var queue = jQuery.queue( this, type, data ); if ( type === "fx" && queue[0] !== "inprogress" ) { @@ -120,7 +118,6 @@ jQuery.fn.extend({ jQuery.dequeue( this, type ); }); }, - // Based off of the plugin by Clint Helfers, with permission. // http://blindsignals.com/index.php/2009/07/jquery-delay/ delay: function( time, type ) { @@ -134,11 +131,9 @@ jQuery.fn.extend({ }, time ); }); }, - clearQueue: function( type ) { return this.queue( type || "fx", [] ); }, - // Get a promise resolved when queues of a certain type // are emptied (fx is the type by default) promise: function( type, object ) { diff --git a/test/unit/effects.js b/test/unit/effects.js index 4f6785111..71a81eef7 100644 --- a/test/unit/effects.js +++ b/test/unit/effects.js @@ -807,7 +807,7 @@ jQuery.checkState = function(){ jQuery.removeData(this, 'olddisplay', true); start(); -} +}; // Chaining Tests test("Chain fadeOut fadeIn", function() { -- cgit v1.2.3 From cb659c6054851dfcc52069885e7b7c0d17ee7097 Mon Sep 17 00:00:00 2001 From: timmywil Date: Mon, 11 Apr 2011 19:30:20 -0400 Subject: retrieving list with getAttribute is fine, no need to add list here anymore --- src/attributes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/attributes.js b/src/attributes.js index c34cd6193..5ccbf2cde 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -479,7 +479,7 @@ jQuery.each([ "selected", "checked", "readOnly", "disabled" ], function( i, name // Some attributes require a special call on IE if ( !jQuery.support.hrefNormalized ) { - jQuery.each([ "href", "src", "width", "height", "list" ], function( i, name ) { + jQuery.each([ "href", "src", "width", "height" ], function( i, name ) { jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { get: function( elem ) { var ret = elem.getAttribute( name, 2 ); -- cgit v1.2.3 From 98da6b13bcc77dc117c68686ef4ed305bd83d400 Mon Sep 17 00:00:00 2001 From: timmywil Date: Mon, 11 Apr 2011 23:59:12 -0400 Subject: Fixes unit/css.js test fail in Safari 5. support.js test was passing erroneously due to the body to which the div was attached having a width of 0 --- src/support.js | 9 ++++++--- test/unit/css.js | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/support.js b/src/support.js index 34960505a..6b19c0830 100644 --- a/src/support.js +++ b/src/support.js @@ -8,6 +8,7 @@ jQuery.support = (function() { select, opt, input, + marginDiv, support, fragment, body, @@ -190,10 +191,12 @@ jQuery.support = (function() { // Fails in WebKit before Feb 2011 nightlies // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right if ( document.defaultView && document.defaultView.getComputedStyle ) { - div.style.width = "1px"; - div.style.marginRight = "0"; + marginDiv = document.createElement('div'); + marginDiv.style.width = "0"; + marginDiv.style.marginRight = "0"; + div.appendChild( marginDiv ); support.reliableMarginRight = - ( parseInt( document.defaultView.getComputedStyle(div).marginRight, 10 ) || 0 ) === 0; + ( parseInt( document.defaultView.getComputedStyle( marginDiv ).marginRight, 10 ) || 0 ) === 0; } // Remove the body element we added diff --git a/test/unit/css.js b/test/unit/css.js index 08f50ef25..b94c6a8d1 100644 --- a/test/unit/css.js +++ b/test/unit/css.js @@ -375,5 +375,5 @@ test("marginRight computed style (bug #3333)", function() { marginRight: 0 }); - equals($div.css("marginRight"), "0px"); + equals($div.css("marginRight"), "0px", "marginRight correctly calculated with a width and display block"); }); -- cgit v1.2.3 From 7bfb6a7dd315f0eda3e5227f7d41e38f66f46549 Mon Sep 17 00:00:00 2001 From: jeresig Date: Tue, 12 Apr 2011 00:29:52 -0400 Subject: Removing un-needed frameElement check as discussed in #8018. Fixes #8108. --- src/event.js | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'src') diff --git a/src/event.js b/src/event.js index 1d9236279..7d5a1097b 100644 --- a/src/event.js +++ b/src/event.js @@ -24,17 +24,6 @@ jQuery.event = { return; } - // TODO :: Use a try/catch until it's safe to pull this out (likely 1.6) - // Minor release fix for bug #8018 - try { - // For whatever reason, IE has trouble passing the window object - // around, causing it to be cloned in the process - if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) { - elem = window; - } - } - catch ( e ) {} - if ( handler === false ) { handler = returnFalse; } else if ( !handler ) { -- cgit v1.2.3 From 0ff4c69929572e107624139851add5c9a5ec28c6 Mon Sep 17 00:00:00 2001 From: jeresig Date: Tue, 12 Apr 2011 00:38:48 -0400 Subject: Some minor code cleanup. --- src/css.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/css.js b/src/css.js index 40e59a85e..8b0fda000 100644 --- a/src/css.js +++ b/src/css.js @@ -122,16 +122,16 @@ jQuery.extend({ }, css: function( elem, name, extra ) { - // Make sure that we're working with the right name - var ret, - hooks; + var ret, hooks; + // Make sure that we're working with the right name name = jQuery.camelCase( name ); hooks = jQuery.cssHooks[ name ]; name = jQuery.cssProps[ name ] || name; + // cssFloat needs a special treatment - if ( name === 'cssFloat' ) { - name = 'float'; + if ( name === "cssFloat" ) { + name = "float"; } // If a hook was provided get the computed value from there -- cgit v1.2.3 From 02e0047e92de0f1575fb92c091806c4eb4b6ef26 Mon Sep 17 00:00:00 2001 From: louisremi Date: Tue, 12 Apr 2011 11:39:21 +0200 Subject: resolve more conflicts --- src/css.js | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src') diff --git a/src/css.js b/src/css.js index 964b18fcd..b2d3af655 100644 --- a/src/css.js +++ b/src/css.js @@ -252,11 +252,7 @@ if ( !jQuery.support.opacity ) { style.filter = ralpha.test(filter) ? filter.replace(ralpha, opacity) : -<<<<<<< HEAD - style.filter + " " + opacity; -======= filter + " " + opacity; ->>>>>>> 312df0441b16981dd697d74fcbc1e1f212b47b7e } }; } -- cgit v1.2.3 From 34adda3c8805557028adf137d73cc13316c28cc8 Mon Sep 17 00:00:00 2001 From: John Resig Date: Tue, 12 Apr 2011 14:58:55 -0400 Subject: Fixing some minor formatting problems. --- src/event.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/event.js b/src/event.js index c22fa4689..d05c37040 100644 --- a/src/event.js +++ b/src/event.js @@ -286,6 +286,7 @@ jQuery.event = { type = type.slice(0, -1); exclusive = true; } + if ( type.indexOf(".") >= 0 ) { // Namespaced trigger; create a regexp to match event type in handle() namespaces = type.split("."); @@ -306,6 +307,7 @@ jQuery.event = { jQuery.extend( jQuery.Event(type), event ) : // Just the event type (string) jQuery.Event(type); + event.namespace = namespaces.join("."); event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)"); event.exclusive = exclusive; @@ -343,7 +345,7 @@ jQuery.event = { event.target = elem; // Clone any incoming data and prepend the event, creating the handler arg list - data = data? jQuery.makeArray( data ) : []; + data = data ? jQuery.makeArray( data ) : []; data.unshift( event ); var cur = elem, -- cgit v1.2.3 From e7787cd09805583ff690d9c5e4b4c58a88393bf9 Mon Sep 17 00:00:00 2001 From: John Resig Date: Tue, 12 Apr 2011 15:54:30 -0400 Subject: More formatting tweaks. --- src/event.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/event.js b/src/event.js index d05c37040..275afdf93 100644 --- a/src/event.js +++ b/src/event.js @@ -350,7 +350,7 @@ jQuery.event = { var cur = elem, // IE doesn't like method names with a colon (#3533, #8272) - ontype = type.indexOf(":") < 0? "on" + type : ""; + ontype = type.indexOf(":") < 0 ? "on" + type : ""; // Fire event on the current element, then bubble up the DOM tree do { @@ -362,7 +362,7 @@ jQuery.event = { } // Trigger an inline bound script - if ( ontype &&jQuery.acceptData( cur ) && cur[ ontype ] && cur[ ontype ].apply( cur, data ) === false ) { + if ( ontype && jQuery.acceptData( cur ) && cur[ ontype ] && cur[ ontype ].apply( cur, data ) === false ) { event.result = false; event.preventDefault(); } -- cgit v1.2.3 From 0d8b247cab2f91e118d0b734028ce827e09a71f7 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Tue, 12 Apr 2011 16:48:22 -0400 Subject: Accessing the 'type' property on VML elements fails on IE. Fixes #7071. --- src/event.js | 4 ++-- test/index.html | 5 +++++ test/unit/event.js | 3 +++ 3 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/event.js b/src/event.js index d6b116d2e..316a7fee1 100644 --- a/src/event.js +++ b/src/event.js @@ -800,7 +800,7 @@ if ( !jQuery.support.changeBubbles ) { beforedeactivate: testChange, click: function( e ) { - var elem = e.target, type = elem.type; + var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : ""; if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) { testChange.call( this, e ); @@ -810,7 +810,7 @@ if ( !jQuery.support.changeBubbles ) { // Change has to be called before submit // Keydown will be called before keypress, which is used in submit-event delegation keydown: function( e ) { - var elem = e.target, type = elem.type; + var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : ""; if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") || (e.keyCode === 32 && (type === "checkbox" || type === "radio")) || diff --git a/test/index.html b/test/index.html index a10655089..bf7dc7989 100644 --- a/test/index.html +++ b/test/index.html @@ -45,6 +45,10 @@ + + + + @@ -147,6 +151,7 @@ test element + Float test. diff --git a/test/unit/event.js b/test/unit/event.js index b46ef9ebb..491396f93 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -776,6 +776,9 @@ test("trigger() shortcuts", function() { // manually clean up detached elements elem.remove(); + + // test that special handlers do not blow up with VML elements (#7071) + jQuery("#oval").click().keydown(); }); test("trigger() bubbling", function() { -- cgit v1.2.3 From 352715bd0802e2df041f86e1a82669574183ec04 Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Tue, 12 Apr 2011 17:46:15 -0400 Subject: Use explicit "new jQuery.Event" to avoid double-function-call overhead. --- src/event.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/event.js b/src/event.js index b8a2e37ec..5e2baf0d2 100644 --- a/src/event.js +++ b/src/event.js @@ -314,9 +314,9 @@ jQuery.event = { // jQuery.Event object event[ jQuery.expando ] ? event : // Object literal - jQuery.extend( jQuery.Event(type), event ) : + jQuery.extend( new jQuery.Event(type), event ) : // Just the event type (string) - jQuery.Event(type); + new jQuery.Event(type); event.namespace = namespaces.join("."); event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)"); event.exclusive = exclusive; @@ -989,7 +989,7 @@ jQuery.fn.extend({ triggerHandler: function( type, data ) { if ( this[0] ) { - var event = jQuery.Event( type ); + var event = new jQuery.Event( type ); event.preventDefault(); event.stopPropagation(); jQuery.event.trigger( event, data, this[0] ); -- cgit v1.2.3 From 73f9ab67058d2dc14ab81c62bd9b228b0e1cad93 Mon Sep 17 00:00:00 2001 From: timmywil Date: Tue, 12 Apr 2011 18:30:21 -0400 Subject: JSLint failed due to function created within for loop --- src/manipulation.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/manipulation.js b/src/manipulation.js index 52d59d83e..711cb5e88 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -553,6 +553,8 @@ jQuery.extend({ }, clean: function( elems, context, fragment, scripts ) { + var checkScriptType; + context = context || document; // !context.createElement fails in IE with an error but returns typeof 'object' @@ -630,15 +632,16 @@ jQuery.extend({ } if ( fragment ) { + checkScriptType = function( elem ) { + return !elem.type || rscriptType.test( elem.type ); + }; for ( i = 0; ret[i]; i++ ) { if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) { scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] ); } else { if ( ret[i].nodeType === 1 ) { - var jsTags = jQuery.grep( ret[i].getElementsByTagName( "script" ), function( elem ) { - return !elem.type || rscriptType.test( elem.type ); - }); + var jsTags = jQuery.grep( ret[i].getElementsByTagName( "script" ), checkScriptType ); ret.splice.apply( ret, [i + 1, 0].concat( jsTags ) ); } -- cgit v1.2.3 From 9e71ad1b120e2b20c7430c017629877ba277f667 Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Tue, 12 Apr 2011 18:32:23 -0400 Subject: Explicitly set event.type in case we chopped out a namespace or exclusive flag. --- src/event.js | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/event.js b/src/event.js index 5e2baf0d2..f6cd97ccf 100644 --- a/src/event.js +++ b/src/event.js @@ -317,6 +317,7 @@ jQuery.event = { jQuery.extend( new jQuery.Event(type), event ) : // Just the event type (string) new jQuery.Event(type); + event.type = type; event.namespace = namespaces.join("."); event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)"); event.exclusive = exclusive; -- cgit v1.2.3 From bebd8bc01e63dcb053412f8b247e4fa611867c55 Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Tue, 12 Apr 2011 19:29:09 -0400 Subject: Followup to #8753. Modify new Event constructor signature to jQuery.event(type, props), which can be exploited by jQuery.event.trigger as well. --- src/event.js | 24 +++++++++--------------- test/unit/event.js | 4 ++-- 2 files changed, 11 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/event.js b/src/event.js index f005f7285..dd48e7f77 100644 --- a/src/event.js +++ b/src/event.js @@ -304,9 +304,9 @@ jQuery.event = { // jQuery.Event object event[ jQuery.expando ] ? event : // Object literal - jQuery.extend( new jQuery.Event(type), event ) : + new jQuery.Event( type, event ) : // Just the event type (string) - new jQuery.Event(type); + new jQuery.Event( type ); event.type = type; event.namespace = namespaces.join("."); @@ -563,26 +563,15 @@ jQuery.removeEvent = document.removeEventListener ? } }; -jQuery.Event = function( src ) { +jQuery.Event = function( src, props ) { // Allow instantiation without the 'new' keyword if ( !this.preventDefault ) { - return new jQuery.Event( src ); + return new jQuery.Event( src, props ); } // Event object if ( src && src.type ) { this.originalEvent = src; - - // Push explicitly provided properties onto the event object - for ( var prop in src ) { - // Ensure we don't clobber jQuery.Event prototype - // with own properties. - if ( hasOwn.call( src, prop ) ) { - this[ prop ] = src[ prop ]; - } - } - - // Always ensure a type has been explicitly set this.type = src.type; // Events bubbling up the document may have been marked as prevented @@ -595,6 +584,11 @@ jQuery.Event = function( src ) { this.type = src; } + // Put explicitly provided properties onto the event object + if ( props ) { + jQuery.extend( this, props ); + } + // timeStamp is buggy for some events on Firefox(#3843) // So we won't rely on the native value this.timeStamp = jQuery.now(); diff --git a/test/unit/event.js b/test/unit/event.js index 491396f93..d4e3994e5 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -978,11 +978,11 @@ test("trigger(eventObject, [data], [fn])", function() { $parent.unbind().remove(); }); -test("jQuery.Event({ /* props */ })", function() { +test("jQuery.Event( type, props )", function() { expect(4); - var event = jQuery.Event({ type: "keydown", keyCode: 64 }), + var event = jQuery.Event( "keydown", { keyCode: 64 }), handler = function( event ) { ok( "keyCode" in event, "Special property 'keyCode' exists" ); equal( event.keyCode, 64, "event.keyCode has explicit value '64'" ); -- cgit v1.2.3 From 4344d0841756f8572c56490f12739ac204f40966 Mon Sep 17 00:00:00 2001 From: jaubourg Date: Wed, 13 Apr 2011 18:35:38 +0200 Subject: Fixes #8635 again (fix was lost in rewrite). Also removes unnecessary "manual" garbage collection. --- src/support.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/support.js b/src/support.js index 6b19c0830..1bd35cab2 100644 --- a/src/support.js +++ b/src/support.js @@ -73,7 +73,7 @@ jQuery.support = (function() { // Make sure that a selected-by-default option has a working selected property. // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) optSelected: opt.selected, - + // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) getSetAttribute: div.className !== "t", @@ -196,7 +196,7 @@ jQuery.support = (function() { marginDiv.style.marginRight = "0"; div.appendChild( marginDiv ); support.reliableMarginRight = - ( parseInt( document.defaultView.getComputedStyle( marginDiv ).marginRight, 10 ) || 0 ) === 0; + ( parseInt( document.defaultView.getComputedStyle( marginDiv, null ).marginRight, 10 ) || 0 ) === 0; } // Remove the body element we added @@ -224,9 +224,6 @@ jQuery.support = (function() { } } - // release memory in IE - body = div = all = a = tds = undefined; - return support; })(); -- cgit v1.2.3 From 4ad9b44deada9da9639f53b1ca3cc4cf2ebf2df2 Mon Sep 17 00:00:00 2001 From: jaubourg Date: Wed, 13 Apr 2011 19:27:19 +0200 Subject: Ensures callback placeholders are tested for and eventually replaced in data only when contentType is application/x-www-form-urlencoded and data is a string. Removes json to jsonp promotion when jsonp or jsonpCallback options are present. Uses new Deferred.always method to bind cleanUp function. --- src/ajax/jsonp.js | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/ajax/jsonp.js b/src/ajax/jsonp.js index 4fb094011..6b0f95d5b 100644 --- a/src/ajax/jsonp.js +++ b/src/ajax/jsonp.js @@ -14,13 +14,12 @@ jQuery.ajaxSetup({ // Detect, normalize options and install callbacks for jsonp requests jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { - var dataIsString = ( typeof s.data === "string" ); + var inspectData = s.contentType === "application/x-www-form-urlencoded" && + ( typeof s.data === "string" ); if ( s.dataTypes[ 0 ] === "jsonp" || - originalSettings.jsonpCallback || - originalSettings.jsonp != null || s.jsonp !== false && ( jsre.test( s.url ) || - dataIsString && jsre.test( s.data ) ) ) { + inspectData && jsre.test( s.data ) ) ) { var responseContainer, jsonpCallback = s.jsonpCallback = @@ -28,20 +27,12 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { previous = window[ jsonpCallback ], url = s.url, data = s.data, - replace = "$1" + jsonpCallback + "$2", - cleanUp = function() { - // Set callback back to previous value - window[ jsonpCallback ] = previous; - // Call if it was a function and we have a response - if ( responseContainer && jQuery.isFunction( previous ) ) { - window[ jsonpCallback ]( responseContainer[ 0 ] ); - } - }; + replace = "$1" + jsonpCallback + "$2"; if ( s.jsonp !== false ) { url = url.replace( jsre, replace ); if ( s.url === url ) { - if ( dataIsString ) { + if ( inspectData ) { data = data.replace( jsre, replace ); } if ( s.data === data ) { @@ -59,8 +50,15 @@ jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) { responseContainer = [ response ]; }; - // Install cleanUp function - jqXHR.then( cleanUp, cleanUp ); + // Clean-up function + jqXHR.always(function() { + // Set callback back to previous value + window[ jsonpCallback ] = previous; + // Call if it was a function and we have a response + if ( responseContainer && jQuery.isFunction( previous ) ) { + window[ jsonpCallback ]( responseContainer[ 0 ] ); + } + }); // Use data converter to retrieve json after script execution s.converters["script json"] = function() { -- cgit v1.2.3 From 42e20269ecf7a300c6dbd7475b8bef2ef160c546 Mon Sep 17 00:00:00 2001 From: jeresig Date: Wed, 13 Apr 2011 16:41:55 -0400 Subject: Updating Sizzle. --- src/sizzle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/sizzle b/src/sizzle index c50b0cdde..69ecd0198 160000 --- a/src/sizzle +++ b/src/sizzle @@ -1 +1 @@ -Subproject commit c50b0cddec48494ba882606d03e14cce647d243b +Subproject commit 69ecd019852c1421cbd81fe6ceb4e22a81022ea7 -- cgit v1.2.3 From 149a040794b3b52bc392281fab68aba40c7018ce Mon Sep 17 00:00:00 2001 From: timmywil Date: Wed, 13 Apr 2011 23:10:32 -0400 Subject: Fix test suite fail in IE6/7 on event:undelegate - was failing an if where it shouldn't --- src/event.js | 4 ++-- test/unit/event.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/event.js b/src/event.js index dd48e7f77..bfd263078 100644 --- a/src/event.js +++ b/src/event.js @@ -960,7 +960,7 @@ jQuery.fn.extend({ undelegate: function( selector, types, fn ) { if ( arguments.length === 0 ) { - return this.unbind( "live" ); + return this.unbind( "live" ); } else { return this.die( types, null, fn, selector ); @@ -1036,7 +1036,7 @@ jQuery.each(["live", "die"], function( i, name ) { } if ( name === "die" && !types && - origSelector && origSelector[0] === "." ) { + origSelector && origSelector.charAt(0) === "." ) { context.unbind( origSelector ); diff --git a/test/unit/event.js b/test/unit/event.js index 687184294..1710f6f98 100644 --- a/test/unit/event.js +++ b/test/unit/event.js @@ -2027,11 +2027,11 @@ test("delegate with submit", function() { jQuery(document).undelegate(); }); -test("undelegate() with only namespaces", function(){ +test("undelegate() with only namespaces", function() { expect(2); var $delegate = jQuery("#liveHandlerOrder"), - count = 0; + count = 0; $delegate.delegate("a", "click.ns", function(e) { count++; -- cgit v1.2.3 From ca5bc202ac37a8e3d5787b24ea3fdc229143802c Mon Sep 17 00:00:00 2001 From: timmywil Date: Wed, 13 Apr 2011 23:45:58 -0400 Subject: IE9's support for SVG elements unfortunately does not extend to clearAttributes. Checks for its presence before proceeding. --- src/manipulation.js | 8 ++++++-- test/unit/attributes.js | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/manipulation.js b/src/manipulation.js index 711cb5e88..f519b4d35 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -388,11 +388,15 @@ function cloneFixAttributes( src, dest ) { // clearAttributes removes the attributes, which we don't want, // but also removes the attachEvent events, which we *do* want - dest.clearAttributes(); + if ( dest.clearAttributes ) { + dest.clearAttributes(); + } // mergeAttributes, in contrast, only merges back on the // original attributes, not the events - dest.mergeAttributes(src); + if ( dest.mergeAttributes ) { + dest.mergeAttributes( src ); + } // IE6-8 fail to clone children inside object elements that use // the proprietary classid attribute value (rather than the type diff --git a/test/unit/attributes.js b/test/unit/attributes.js index 2bcc5046e..87fa5625f 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -285,7 +285,7 @@ test("attr(String, Object)", function() { equals( "button", button.attr("type"), "Verify that you can't change the type of a button element" ); // Setting attributes on svg elements (bug #3116) - var $svg = jQuery("" + var $svg = jQuery("" + "" + "").appendTo("body"); equals( $svg.attr("cx", 100).attr("cx"), "100", "Set attribute on svg element" ); -- cgit v1.2.3