Merge branch 'jquerymaster' of http://github.com/SlexAxton/jquery into SlexAxton...
authorJohn Resig <jeresig@gmail.com>
Mon, 25 Oct 2010 20:06:55 +0000 (13:06 -0700)
committerJohn Resig <jeresig@gmail.com>
Mon, 25 Oct 2010 20:06:55 +0000 (13:06 -0700)
14 files changed:
Makefile
src/ajax.js
src/attributes.js
src/core.js
src/css.js
src/data.js
src/dimensions.js
src/effects.js
src/event.js
src/support.js
test/unit/ajax.js
test/unit/css.js
test/unit/event.js
test/unit/selector.js

index 6b46c7d..0dae732 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -39,7 +39,7 @@ SIZZLE_DIR = ${SRC_DIR}/sizzle
 QUNIT_DIR = ${TEST_DIR}/qunit
 
 JQ_VER = $(shell cat version.txt)
-VER = sed s/@VERSION/${JQ_VER}/
+VER = sed "s/@VERSION/${JQ_VER}/"
 
 DATE=$(shell git log -1 --pretty=format:%ad)
 
index d6c35d4..b39bc8d 100644 (file)
@@ -4,7 +4,7 @@ var jsc = jQuery.now(),
        rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
        rselectTextarea = /^(?:select|textarea)/i,
        rinput = /^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
-       rnoContent = /^(?:GET|HEAD|DELETE)$/,
+       rnoContent = /^(?:GET|HEAD)$/,
        rbracket = /\[\]$/,
        jsre = /\=\?(&|$)/,
        rquery = /\?/,
@@ -208,6 +208,12 @@ jQuery.extend({
                        s.data = jQuery.param( s.data, s.traditional );
                }
 
+               // If the jsonpCallback has been set, we can assume that dataType is jsonp
+               // Ticket #5803
+               if ( s.jsonpCallback ) {
+                 s.dataType = "jsonp";
+               }
+
                // Handle JSONP Parameter Callbacks
                if ( s.dataType === "jsonp" ) {
                        if ( type === "GET" ) {
@@ -265,7 +271,7 @@ jQuery.extend({
                        s.cache = false;
                }
 
-               if ( s.cache === false && type === "GET" ) {
+               if ( s.cache === false && noContent ) {
                        var ts = jQuery.now();
 
                        // try replacing _= if it is there
@@ -275,8 +281,8 @@ jQuery.extend({
                        s.url = ret + ((ret === s.url) ? (rquery.test(s.url) ? "&" : "?") + "_=" + ts : "");
                }
 
-               // If data is available, append data to url for get requests
-               if ( s.data && type === "GET" ) {
+               // If data is available, append data to url for GET/HEAD requests
+               if ( s.data && noContent ) {
                        s.url += (rquery.test(s.url) ? "&" : "?") + s.data;
                }
 
index 147c353..4393a9f 100644 (file)
@@ -9,6 +9,19 @@ var rclass = /[\n\t]/g,
        rclickable = /^a(?:rea)?$/i,
        rradiocheck = /^(?:radio|checkbox)$/i;
 
+jQuery.props = {
+       "for": "htmlFor",
+       "class": "className",
+       readonly: "readOnly",
+       maxlength: "maxLength",
+       cellspacing: "cellSpacing",
+       rowspan: "rowSpan",
+       colspan: "colSpan",
+       tabindex: "tabIndex",
+       usemap: "useMap",
+       frameborder: "frameBorder"
+};
+
 jQuery.fn.extend({
        attr: function( name, value ) {
                return jQuery.access( this, name, value, true, jQuery.attr );
index 99521d9..3a37c4a 100644 (file)
@@ -424,8 +424,8 @@ jQuery.extend({
                        }
 
                        // Trigger any bound ready events
-                       if ( jQuery.fn.triggerHandler ) {
-                               jQuery( document ).triggerHandler( "ready" );
+                       if ( jQuery.fn.trigger ) {
+                               jQuery( document ).trigger( "ready" ).unbind( "ready" );
                        }
                }
        },
index 933d2b4..30cecf3 100644 (file)
@@ -169,7 +169,19 @@ jQuery.each(["height", "width"], function( i, name ) {
                                        });
                                }
 
-                               return val + "px";
+                               if ( val <= 0 ) {
+                                       val = curCSS( elem, name, name );
+
+                                       if ( val != null ) {
+                                               return val === "auto" ? "" : val;
+                                       }
+                               }
+
+                               if ( val < 0 || val == null ) {
+                                       return elem.style[ name ];
+                               }
+
+                               return typeof val === "string" ? val : val + "px";
                        }
                },
 
index 31cdc12..0407f73 100644 (file)
@@ -134,9 +134,9 @@ jQuery.extend({
 
 jQuery.fn.extend({
        data: function( key, value ) {
-               if ( typeof key === "undefined" ) {
-                       var data = null;
+               var data = null;
 
+               if ( typeof key === "undefined" ) {
                        if ( this.length ) {
                                var attr = this[0].attributes, name;
                                data = jQuery.data( this[0] );
@@ -163,7 +163,7 @@ jQuery.fn.extend({
                parts[1] = parts[1] ? "." + parts[1] : "";
 
                if ( value === undefined ) {
-                       var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
+                       data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
 
                        // Try to fetch any internally stored data first
                        if ( data === undefined && this.length ) {
index 5aafbf4..f5212e1 100644 (file)
@@ -33,27 +33,29 @@ jQuery.each([ "Height", "Width" ], function( i, name ) {
                        });
                }
 
-               return jQuery.isWindow( elem ) ?
+               if ( jQuery.isWindow( elem ) ) {
                        // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
-                       elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] ||
-                       elem.document.body[ "client" + name ] :
-
-                       // Get document width or height
-                       (elem.nodeType === 9) ? // is it a document
-                               // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
-                               Math.max(
-                                       elem.documentElement["client" + name],
-                                       elem.body["scroll" + name], elem.documentElement["scroll" + name],
-                                       elem.body["offset" + name], elem.documentElement["offset" + name]
-                               ) :
-
-                               // Get or set width or height on the element
-                               size === undefined ?
-                                       // Get width or height on the element
-                                       parseFloat( jQuery.css( elem, type ) ) :
-
-                                       // Set the width or height on the element (default to pixels if value is unitless)
-                                       this.css( type, typeof size === "string" ? size : size + "px" );
+                       return elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] ||
+                               elem.document.body[ "client" + name ];
+
+               // Get document width or height
+               } else if ( elem.nodeType === 9 ) {
+                       // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
+                       return Math.max(
+                               elem.documentElement["client" + name],
+                               elem.body["scroll" + name], elem.documentElement["scroll" + name],
+                               elem.body["offset" + name], elem.documentElement["offset" + name]
+                       );
+
+               // Get or set width or height on the element
+               } else if ( size === undefined ) {
+                       var orig = jQuery.css( elem, type ), ret = parseFloat( orig );
+                       return jQuery.isNaN( ret ) ? orig : ret;
+
+               // Set the width or height on the element (default to pixels if value is unitless)
+               } else {
+                       return this.css( type, typeof size === "string" ? size : size + "px" );
+               }
        };
 
 });
index d7896c0..44a7942 100644 (file)
@@ -174,7 +174,7 @@ jQuery.fn.extend({
 
                                } else {
                                        var parts = rfxnum.exec(val),
-                                               start = e.cur(true) || 0;
+                                               start = e.cur() || 0;
 
                                        if ( parts ) {
                                                var end = parseFloat( parts[2] ),
@@ -183,7 +183,7 @@ jQuery.fn.extend({
                                                // We need to compute starting value
                                                if ( unit !== "px" ) {
                                                        jQuery.style( self, name, (end || 1) + unit);
-                                                       start = ((end || 1) / e.cur(true)) * start;
+                                                       start = ((end || 1) / e.cur()) * start;
                                                        jQuery.style( self, name, start + unit);
                                                }
 
index fb5a3ef..959e89c 100644 (file)
@@ -32,6 +32,9 @@ jQuery.event = {
 
                if ( handler === false ) {
                        handler = returnFalse;
+               } else if ( !handler ) {
+                 // Fixes bug #7229. Fix recommended by jdalton
+                 return;
                }
 
                var handleObjIn, handleObj;
@@ -1129,6 +1132,9 @@ function liveHandler( event ) {
                        if ( ret === false ) {
                                stop = false;
                        }
+                       if ( event.isImmediatePropagationStopped() ) {
+                               break;
+                       }
                }
        }
 
index b9c10c7..67b41c4 100644 (file)
        // release memory in IE
        root = script = div = all = a = null;
 })();
-
-jQuery.props = {
-       "for": "htmlFor",
-       "class": "className",
-       readonly: "readOnly",
-       maxlength: "maxLength",
-       cellspacing: "cellSpacing",
-       rowspan: "rowSpan",
-       colspan: "colSpan",
-       tabindex: "tabIndex",
-       usemap: "useMap",
-       frameborder: "frameBorder"
-};
-
 })( jQuery );
index 5704d73..7344659 100644 (file)
@@ -289,6 +289,32 @@ test("jQuery.ajax - xml: non-namespace elements inside namespaced elements", fun
        });
 });
 
+test("jQuery.ajax - HEAD requests", function() {
+       expect(2);
+
+       stop();
+       jQuery.ajax({
+               url: url("data/name.html"),
+               type: "HEAD",
+               success: function(data, status, xhr){
+                       var h = xhr.getAllResponseHeaders();
+                       ok( /Date/i.test(h), 'No Date in HEAD response' );
+                       
+                       jQuery.ajax({
+                               url: url("data/name.html"),
+                               data: { whip_it: "good" },
+                               type: "HEAD",
+                               success: function(data, status, xhr){
+                                       var h = xhr.getAllResponseHeaders();
+                                       ok( /Date/i.test(h), 'No Date in HEAD response with data' );
+                                       start();
+                               }
+                       });
+               }
+       });
+       
+});
+
 test("jQuery.ajax - beforeSend", function() {
        expect(1);
        stop();
@@ -799,6 +825,21 @@ test("jQuery.ajax() - JSONP, Local", function() {
                        plus();
                }
        });
+       
+  // Supports Ticket #5803     
+       jQuery.ajax({
+               url: "data/jsonp.php",
+               jsonpCallback: "jsonpResults",
+               success: function(data){
+                       ok( data.data, "JSON results returned without dataType:jsonp when jsonpCallback is defined" );
+                       plus();
+               },
+               error: function(data){
+                       ok( false, "Ajax error JSON (GET, custom callback name)" );
+                       plus();
+               }
+       });             
+       
 });
 
 test("JSONP - Custom JSONP Callback", function() {
index 40959b1..9c262af 100644 (file)
@@ -1,7 +1,7 @@
 module("css");
 
 test("css(String|Hash)", function() {
-       expect(34);
+       expect(41);
 
        equals( jQuery('#main').css("display"), 'block', 'Check for css property "display"');
 
@@ -11,6 +11,24 @@ test("css(String|Hash)", function() {
        jQuery('#nothiddendiv').css({display: 'block'});
        ok( jQuery('#nothiddendiv').is(':visible'), 'Modified CSS display: Assert element is visible');
 
+       var div = jQuery( "<div>" );
+
+       equals( div.css("width"), "", "Width on disconnected node." );
+       equals( div.css("height"), "", "Height on disconnected node." );
+
+       div.css({ width: 4, height: 4 });
+
+       equals( div.css("width"), "4px", "Width on disconnected node." );
+       equals( div.css("height"), "4px", "Height on disconnected node." );
+
+       var div2 = jQuery( "<div style='display:none;'><input type='text' style='height:20px;'/><textarea style='height:20px;'/><div style='height:20px;'></div></div>").appendTo("body");
+
+       equals( div2.find("input").css("height"), "20px", "Height on hidden input." );
+       equals( div2.find("textarea").css("height"), "20px", "Height on hidden textarea." );
+       equals( div2.find("div").css("height"), "20px", "Height on hidden textarea." );
+
+       div2.remove();
+
        // handle negative numbers by ignoring #1599, #4216
        jQuery('#nothiddendiv').css({ 'width': 1, 'height': 1 });
 
index f3d3148..54431dd 100644 (file)
@@ -1,5 +1,25 @@
 module("event");
 
+test("null or undefined handler", function() {
+       expect(2);
+  // Supports Fixes bug #7229
+  try {
+  
+    jQuery("#firstp").click(null);
+  
+    ok(true, "Passing a null handler will not throw an exception");
+
+  } catch (e) {}  
+
+  try {
+  
+    jQuery("#firstp").click(undefined);
+  
+    ok(true, "Passing an undefined handler will not throw an exception");
+
+  } catch (e) {}  
+});
+
 test("bind(), with data", function() {
        expect(3);
        var handler = function(event) {
@@ -245,6 +265,36 @@ test("live/die(Object), delegate/undelegate(String, Object)", function() {
        equals( mouseoverCounter, 4, "die" );
 });
 
+test("live/delegate immediate propagation", function() {
+       expect(2);
+       
+       var $p = jQuery("#firstp"), $a = $p.find("a:first"), lastClick;
+       
+       lastClick = "";
+       $a.live( "click", function(e) { 
+               lastClick = "click1"; 
+               e.stopImmediatePropagation();
+       });
+       $a.live( "click", function(e) {
+               lastClick = "click2";
+       });
+       $a.trigger( "click" );
+       equals( lastClick, "click1", "live stopImmediatePropagation" );
+       $a.die( "click" );
+       
+       lastClick = "";
+       $p.delegate( "a", "click", function(e) { 
+               lastClick = "click1"; 
+               e.stopImmediatePropagation();
+       });
+       $p.delegate( "a", "click", function(e) {
+               lastClick = "click2";
+       });
+       $a.trigger( "click" );
+       equals( lastClick, "click1", "delegate stopImmediatePropagation" );
+       $p.undelegate( "click" );
+});
+
 test("bind(), iframes", function() {
        // events don't work with iframes, see #939 - this test fails in IE because of contentDocument
        var doc = jQuery("#loadediframe").contents();
index 622e37e..856257f 100644 (file)
@@ -36,7 +36,7 @@ test("element", function() {
 
 if ( location.protocol != "file:" ) {
        test("XML Document Selectors", function() {
-               expect(7);
+               expect(8);
                stop();
                jQuery.get("data/with_fries.xml", function(xml) {
                        equals( jQuery("foo_bar", xml).length, 1, "Element Selector with underscore" );
@@ -46,6 +46,7 @@ if ( location.protocol != "file:" ) {
                        equals( jQuery("[name=prop2]", xml).length, 1, "Attribute selector with name" );
                        equals( jQuery("#seite1", xml).length, 1, "Attribute selector with ID" );
                        equals( jQuery("component#seite1", xml).length, 1, "Attribute selector with ID" );
+                       equals( jQuery("component", xml).filter("#seite1").length, 1, "Attribute selector filter with ID" );
                        start();
                });
        });
@@ -153,7 +154,7 @@ test("class", function() {
 });
 
 test("name", function() {
-       expect(14);
+       expect(15);
 
        t( "Name selector", "input[name=action]", ["text1"] );
        t( "Name selector with single quotes", "input[name='action']", ["text1"] );
@@ -168,6 +169,12 @@ test("name", function() {
        same( jQuery("#form").find("input[name=action]").get(), q("text1"), "Name selector within the context of another element" );
        same( jQuery("#form").find("input[name='foo[bar]']").get(), q("hidden2"), "Name selector for grouped form element within the context of another element" );
 
+       var form = jQuery("<form><input name='id'/></form>").appendTo("body");
+
+       equals( form.find("input").length, 1, "Make sure that rooted queries on forms (with possible expandos) work." );
+
+       form.remove();
+
        var a = jQuery('<div><a id="tName1ID" name="tName1">tName1 A</a><a id="tName2ID" name="tName2">tName2 A</a><div id="tName1">tName1 Div</div></div>').appendTo('#main').children();
 
        equals( a.length, 3, "Make sure the right number of elements were inserted." );
@@ -225,7 +232,7 @@ test("child and adjacent", function() {
 });
 
 test("attributes", function() {
-       expect(34);
+       expect(35);
        t( "Attribute Exists", "a[title]", ["google"] );
        t( "Attribute Exists", "*[title]", ["google"] );
        t( "Attribute Exists", "[title]", ["google"] );
@@ -263,6 +270,9 @@ test("attributes", function() {
        t( "Attribute Contains", "a[href *= 'google']", ["google","groups"] );
        t( "Attribute Is Not Equal", "#ap a[hreflang!='en']", ["google","groups","anchor1"] );
 
+       var opt = document.getElementById("option1a");
+       ok( (window.Sizzle || window.jQuery.find).matchesSelector( opt, "[id*=option1][type!=checkbox]" ), "Attribute Is Not Equal Matches" );
+
        t("Empty values", "#select1 option[value='']", ["option1a"]);
        t("Empty values", "#select1 option[value!='']", ["option1b","option1c","option1d"]);
        
@@ -320,10 +330,13 @@ test("pseudo - child", function() {
 });
 
 test("pseudo - misc", function() {
-       expect(6);
+       expect(7);
 
        t( "Headers", ":header", ["qunit-header", "qunit-banner", "qunit-userAgent"] );
        t( "Has Children - :has()", "p:has(a)", ["firstp","ap","en","sap"] );
+       
+       var select = document.getElementById("select1");
+       ok( (window.Sizzle || window.jQuery.find).matchesSelector( select, ":has(option)" ), "Has Option Matches" );
 
        t( "Text Contains", "a:contains(Google)", ["google","groups"] );
        t( "Text Contains", "a:contains(Google Groups)", ["groups"] );