Merge branch 'unusedTrue' of http://github.com/lrbabe/jquery into lrbabe-unusedTrue
authorJohn Resig <jeresig@gmail.com>
Mon, 25 Oct 2010 19:36:40 +0000 (12:36 -0700)
committerJohn Resig <jeresig@gmail.com>
Mon, 25 Oct 2010 19:36:40 +0000 (12:36 -0700)
Makefile
src/core.js
src/css.js
src/data.js
src/dimensions.js
test/unit/css.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 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 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 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"] );