From 547570a9b272c0c7d70c996a8139d26a118dd838 Mon Sep 17 00:00:00 2001 From: Phil Mander Date: Thu, 27 Oct 2011 22:55:25 +0200 Subject: [PATCH 1/6] Signed-off-by: Phil Mander --- build/google-compiler-20100917.jar | Bin 3939454 -> 3939413 bytes build/js.jar | Bin 812869 -> 812861 bytes test/data/text.php | 24 +- test/delegatetest.html | 484 ++++++++++++++--------------- 4 files changed, 254 insertions(+), 254 deletions(-) diff --git a/build/google-compiler-20100917.jar b/build/google-compiler-20100917.jar index 4dfa5ad0b9554ceff8720f2e2ab9c3caa25a1d5f..02c76c08079d882140de8311c367aa405745c04a 100644 GIT binary patch delta 426 zcmWN~Pbjki90%~Q_jxemnHlzO-i_^j&Hwk=*xq;E13ecd+JVU1TS{K##4g;3^dr+I z!}7M9w&GQ9DPQd}Im(|T<>27L4ob+9gYEqtKIcz*|1s;5{d@7wro2dbvpV0=-kp7? zCi_4(%Yl7B)gfbiQS~!~6Y~cp39Tr|3#0@ECbC?X$MTsPO0eKsBult}X)VVNaJig)mp*k6@)re=trxAw7CRrCXzvNtYs%F4F~} z3zSDUDeg3|kBB>s&I&wujq`_?(3$!?bk=2J6*%kqbaIJ^)ts2XuRrFQBf1&3;AXh8 zcbi<=D!8=PJO{NYRSVC zaGAtd9mH7u>Til@8dxJDnkL^ANlQ)aE2Jgaqef>~zO95Dmy;?oBxL4bP8br+{VwvQ on&C^e@DdPR>jBZN;6ij?jm7>>x=U!s?`GfFcjm#4zx6!uALmfE&j0`b delta 508 zcmW-dUnoOy9L2jcF6OeCF}4}@$NxXqFlOapkT6%^u|QN!KZ`aWx5#a$j~KpSfdLM3b*zkr?99S2wt4-!BkkdW1#bkCw!dXoT0N^kPs zGwz+wrW6U#mlWwM-l02{RJ)Gd*P#^1Kq`G5%73oVMVx8ECUh=OaXNxcqenrFp7h;8 z_)s*RLeUJl8@*^r>DxlKW6A_sv}014G=JZAs9a~z9=W>Rg5Gae0}c7@*_SuS=XKhX zF=*30n}&LN>3R8UCZEr0){ z(91vMLX-V`P>eo&%!5i`qVRE5M-4K2xQguI>i>5K*qXHg)@;L-eb#(C%y8SzadR40 RPQeUnK^?G=Q>edQ`UO?fzuW)- diff --git a/build/js.jar b/build/js.jar index a76cc7c6b23acae0002e745dabdda30a013dae4c..6658c790932f01de2d5de6516294393360c36a25 100644 GIT binary patch delta 87 zcmX?l&T#KJ!-g%4AFpr!be(avPy0L-CLm@8VwUamR9GJhZ*Q<*ja$)v{{bryvjH*t o_WKVwtn9W+$#Z@c+%90qc{q6cl@`wSH|;TnT-##`xnF(-05jq#3;+NC delta 103 zcmdmc&hY3t!-g%4AFng=ZU+*peHeM$=cq6NF*6XeY@egT`cN1sS8KrAbqxlv;7TFZAc;4_K-sEmtO&=-zh!- diff --git a/test/data/text.php b/test/data/text.php index c06ef4b8eb..b9df4cf3bb 100644 --- a/test/data/text.php +++ b/test/data/text.php @@ -1,12 +1,12 @@ -Lorem ipsum dolor sit amet -consectetuer adipiscing elit -Sed lorem leo -lorem leo consectetuer adipiscing elit -Sed lorem leo -rhoncus sit amet -elementum at -bibendum at, eros -Cras at mi et tortor egestas vestibulum -sed Cras at mi vestibulum -Phasellus sed felis sit amet -orci dapibus semper. +Lorem ipsum dolor sit amet +consectetuer adipiscing elit +Sed lorem leo +lorem leo consectetuer adipiscing elit +Sed lorem leo +rhoncus sit amet +elementum at +bibendum at, eros +Cras at mi et tortor egestas vestibulum +sed Cras at mi vestibulum +Phasellus sed felis sit amet +orci dapibus semper. diff --git a/test/delegatetest.html b/test/delegatetest.html index b2840c1292..327085c84b 100644 --- a/test/delegatetest.html +++ b/test/delegatetest.html @@ -1,242 +1,242 @@ - - - - - - -

Change Tests

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Change each: - - - - - - - -
- - - - -
- -
- - - - -
- - - - - - - $(document).bind('change')
Live:SELECTMULTICHECKBOXRADIOFILETEXTTEXTAREADOCUMENT
Bind:SELECTMULTICHECKBOXRADIOFILETEXTTEXTAREA
Focusin:SELECTMULTICHECKBOXRADIOFILETEXTTEXTAREADOCUMENT
Focusout:SELECTMULTICHECKBOXRADIOFILETEXTTEXTAREADOCUMENT
Live Focus:SELECTMULTICHECKBOXRADIOFILETEXTTEXTAREA
Live Blur:SELECTMULTICHECKBOXRADIOFILETEXTTEXTAREA
-

Submit Tests

- - - - - - - - - - - - - - - -
- Submit each: - -
- -
-
-
- -
-
-
- -
-
$(document).bind('submit')
Results:TEXTPASSWORDBUTTONDOCUMENT
- -
    - - - - + + + + + + +

    Change Tests

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + Change each: + + + + + + + +
    + + + + +
    + +
    + + + + +
    + + + + + + + $(document).bind('change')
    Live:SELECTMULTICHECKBOXRADIOFILETEXTTEXTAREADOCUMENT
    Bind:SELECTMULTICHECKBOXRADIOFILETEXTTEXTAREA
    Focusin:SELECTMULTICHECKBOXRADIOFILETEXTTEXTAREADOCUMENT
    Focusout:SELECTMULTICHECKBOXRADIOFILETEXTTEXTAREADOCUMENT
    Live Focus:SELECTMULTICHECKBOXRADIOFILETEXTTEXTAREA
    Live Blur:SELECTMULTICHECKBOXRADIOFILETEXTTEXTAREA
    +

    Submit Tests

    + + + + + + + + + + + + + + + +
    + Submit each: + +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    $(document).bind('submit')
    Results:TEXTPASSWORDBUTTONDOCUMENT
    + +
      + + + + From 14f620356cc7c6648343ffaa267d1a30e0cb5b54 Mon Sep 17 00:00:00 2001 From: Phil Mander Date: Fri, 28 Oct 2011 22:05:22 +0200 Subject: [PATCH 2/6] Added hasAttrToken and hasRel Signed-off-by: Phil Mander --- src/attributes.js | 19 +++++++++++++++---- test/unit/attributes.js | 26 ++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/src/attributes.js b/src/attributes.js index b7c1f4a825..4b9deff715 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -141,14 +141,25 @@ jQuery.fn.extend({ this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; } }); - }, - + }, + hasClass: function( selector ) { - var className = " " + selector + " ", + return this.hasAttrToken( "class", selector ); + }, + + hasRel: function( selector ) { + return this.hasAttrToken( "rel", selector ); + }, + + hasAttrToken: function( attr, selector ) { + var token = " " + selector + " ", + attrVal, i = 0, l = this.length; + for ( ; i < l; i++ ) { - if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) { + attrVal = attr == "class" ? this[i].className : jQuery(this[i]).attr(attr); + if (attrVal !== undefined && this[i].nodeType === 1 && (" " + attrVal + " ").replace(rclass, " ").indexOf( token ) > -1 ) { return true; } } diff --git a/test/unit/attributes.js b/test/unit/attributes.js index a9d79462d4..3bb5bb89e1 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -1170,3 +1170,29 @@ test("contents().hasClass() returns correct values", function() { ok( $contents.hasClass("foo"), "Found 'foo' in $contents" ); ok( !$contents.hasClass("undefined"), "Did not find 'undefined' in $contents (correctly)" ); }); + +test("hasRel, hasAttrToken", function() { + + expect(10); + + var $div = jQuery("
      Geoff Capes
      "); + + ok( $div.hasAttrToken("data-name", "geoff")); + ok( $div.hasAttrToken("data-name", "capes")); + ok( $div.hasAttrToken("data-name", "love")); + ok( !$div.hasAttrToken("data-name", "lov")); + ok( !$div.hasAttrToken("data-name")); + ok( !$div.hasAttrToken("data-blah")); + + var $a = jQuery("Hi"); + $a.attr("rel", "hi foo bar"); + + var $a2 = jQuery("Bye"); + $a2.attr("rel", "foo hi"); + $a.add($a2); + + ok( $a.hasRel("foo")); + ok( $a.hasRel("hi")); + ok( $a.hasRel("bar")); + ok( !$a.hasRel("foobar")); +}); \ No newline at end of file From 5e66ed39358174d44bd1b71a3fc5f60cb1c71037 Mon Sep 17 00:00:00 2001 From: Phil Mander Date: Fri, 28 Oct 2011 23:02:57 +0200 Subject: [PATCH 3/6] Added case sensitivity to hasAttrToken Signed-off-by: Phil Mander --- src/attributes.js | 12 +++++++++--- test/unit/attributes.js | 17 ++++++++++------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/attributes.js b/src/attributes.js index 4b9deff715..6d5a6616b1 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -148,18 +148,24 @@ jQuery.fn.extend({ }, hasRel: function( selector ) { - return this.hasAttrToken( "rel", selector ); + return this.hasAttrToken( "rel", selector, true ); }, - hasAttrToken: function( attr, selector ) { + hasAttrToken: function( attr, selector, ignoreCase ) { var token = " " + selector + " ", attrVal, + hasToken, i = 0, l = this.length; + + if(ignoreCase === true) { + token = new RegExp(token, "i"); + } for ( ; i < l; i++ ) { attrVal = attr == "class" ? this[i].className : jQuery(this[i]).attr(attr); - if (attrVal !== undefined && this[i].nodeType === 1 && (" " + attrVal + " ").replace(rclass, " ").indexOf( token ) > -1 ) { + hasToken = attrVal !== undefined && this[i].nodeType === 1 && (" " + attrVal + " ").replace(rclass, " ").match( token ); + if (hasToken && hasToken.length) { return true; } } diff --git a/test/unit/attributes.js b/test/unit/attributes.js index 3bb5bb89e1..ee24521f69 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -1173,7 +1173,7 @@ test("contents().hasClass() returns correct values", function() { test("hasRel, hasAttrToken", function() { - expect(10); + expect(13); var $div = jQuery("
      Geoff Capes
      "); @@ -1185,14 +1185,17 @@ test("hasRel, hasAttrToken", function() { ok( !$div.hasAttrToken("data-blah")); var $a = jQuery("Hi"); - $a.attr("rel", "hi foo bar"); + $a.attr("rel", "author nofollow next"); var $a2 = jQuery("Bye"); - $a2.attr("rel", "foo hi"); + $a2.attr("rel", "author next"); $a.add($a2); - ok( $a.hasRel("foo")); - ok( $a.hasRel("hi")); - ok( $a.hasRel("bar")); - ok( !$a.hasRel("foobar")); + ok( $a.hasRel("author")); + ok( $a.hasRel("nofollow")); + ok( $a.hasRel("next")); + ok( $a.hasRel("AUTHOR")); + ok( $a.hasRel("NOFOLLOW")); + ok( $a.hasRel("NEXT")); + ok( !$a.hasRel("nofollownext")); }); \ No newline at end of file From 66afe18abfd78d0b6015f642c42b841db565bb1c Mon Sep 17 00:00:00 2001 From: Phil Mander Date: Fri, 28 Oct 2011 23:13:59 +0200 Subject: [PATCH 4/6] Small tidy up to hasAttrToken Signed-off-by: Phil Mander --- src/attributes.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/attributes.js b/src/attributes.js index 6d5a6616b1..063f4558d3 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -164,8 +164,7 @@ jQuery.fn.extend({ for ( ; i < l; i++ ) { attrVal = attr == "class" ? this[i].className : jQuery(this[i]).attr(attr); - hasToken = attrVal !== undefined && this[i].nodeType === 1 && (" " + attrVal + " ").replace(rclass, " ").match( token ); - if (hasToken && hasToken.length) { + if(attrVal !== undefined && this[i].nodeType === 1 && (" " + attrVal + " ").replace(rclass, " ").match( token )) { return true; } } From 4e57e09f24d7a8de504c3827d5b9788528ec083d Mon Sep 17 00:00:00 2001 From: Phil Mander Date: Fri, 28 Oct 2011 23:21:23 +0200 Subject: [PATCH 5/6] Added test messages Signed-off-by: Phil Mander --- test/unit/attributes.js | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/test/unit/attributes.js b/test/unit/attributes.js index ee24521f69..00d780832a 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -1122,7 +1122,7 @@ test("toggleClass(Fucntion[, boolean]) with incoming value", function() { }); test("addClass, removeClass, hasClass", function() { - expect(17); + expect(18); var jq = jQuery("

      Hi

      "), x = jq[0]; @@ -1150,6 +1150,8 @@ test("addClass, removeClass, hasClass", function() { ok( jq.hasClass("cla.ss3"), "Check hasClass with dot" ); ok( jq.hasClass("class4"), "Check hasClass with carriage return" ); ok( jq.is(".class4"), "Check is with carriage return" ); + + ok( !jq.hasClass("CLASS4"), "Check case sensitivity"); jq.removeClass("class2"); ok( jq.hasClass("class2")==false, "Check the class has been properly removed" ); @@ -1177,12 +1179,12 @@ test("hasRel, hasAttrToken", function() { var $div = jQuery("
      Geoff Capes
      "); - ok( $div.hasAttrToken("data-name", "geoff")); - ok( $div.hasAttrToken("data-name", "capes")); - ok( $div.hasAttrToken("data-name", "love")); - ok( !$div.hasAttrToken("data-name", "lov")); - ok( !$div.hasAttrToken("data-name")); - ok( !$div.hasAttrToken("data-blah")); + ok( $div.hasAttrToken("data-name", "geoff"), "Check token is found"); + ok( $div.hasAttrToken("data-name", "capes"), "Check token is found"); + ok( $div.hasAttrToken("data-name", "love"), "Check token is found"); + ok( !$div.hasAttrToken("data-name", "lov"), "Check non existent token not found"); + ok( !$div.hasAttrToken("data-name"), "Check not attr value not found"); + ok( !$div.hasAttrToken("data-blah"), "Check non existent attr is false"); var $a = jQuery("Hi"); $a.attr("rel", "author nofollow next"); @@ -1191,11 +1193,11 @@ test("hasRel, hasAttrToken", function() { $a2.attr("rel", "author next"); $a.add($a2); - ok( $a.hasRel("author")); - ok( $a.hasRel("nofollow")); - ok( $a.hasRel("next")); - ok( $a.hasRel("AUTHOR")); - ok( $a.hasRel("NOFOLLOW")); - ok( $a.hasRel("NEXT")); - ok( !$a.hasRel("nofollownext")); + ok( $a.hasRel("author"), "Check rel is found"); + ok( $a.hasRel("nofollow"), "Check rel is found"); + ok( $a.hasRel("next"), "Check rel is found"); + ok( $a.hasRel("AUTHOR"), "Check rel is found (not case sensitive)"); + ok( $a.hasRel("NOFOLLOW"), "Check rel is found (not case sensitive)"); + ok( $a.hasRel("NEXT"), "Check rel is found (not case sensitive)"); + ok( !$a.hasRel("nofollownext"), "Check rel is not found"); }); \ No newline at end of file From a85e78df1981ddf8c2320801a85e9e05217cd26b Mon Sep 17 00:00:00 2001 From: Phil Mander Date: Sat, 29 Oct 2011 00:39:33 +0200 Subject: [PATCH 6/6] Removed hasRel method. Updated tests Signed-off-by: Phil Mander --- src/attributes.js | 6 +----- test/unit/attributes.js | 30 +++++++++++++++--------------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/attributes.js b/src/attributes.js index 063f4558d3..2043eaba79 100644 --- a/src/attributes.js +++ b/src/attributes.js @@ -147,17 +147,13 @@ jQuery.fn.extend({ return this.hasAttrToken( "class", selector ); }, - hasRel: function( selector ) { - return this.hasAttrToken( "rel", selector, true ); - }, - hasAttrToken: function( attr, selector, ignoreCase ) { var token = " " + selector + " ", attrVal, hasToken, i = 0, l = this.length; - + if(ignoreCase === true) { token = new RegExp(token, "i"); } diff --git a/test/unit/attributes.js b/test/unit/attributes.js index 00d780832a..f9a94252f9 100644 --- a/test/unit/attributes.js +++ b/test/unit/attributes.js @@ -1173,18 +1173,18 @@ test("contents().hasClass() returns correct values", function() { ok( !$contents.hasClass("undefined"), "Did not find 'undefined' in $contents (correctly)" ); }); -test("hasRel, hasAttrToken", function() { +test("hasAttrToken", function() { expect(13); - var $div = jQuery("
      Geoff Capes
      "); + var $div = jQuery(""); - ok( $div.hasAttrToken("data-name", "geoff"), "Check token is found"); - ok( $div.hasAttrToken("data-name", "capes"), "Check token is found"); - ok( $div.hasAttrToken("data-name", "love"), "Check token is found"); - ok( !$div.hasAttrToken("data-name", "lov"), "Check non existent token not found"); - ok( !$div.hasAttrToken("data-name"), "Check not attr value not found"); - ok( !$div.hasAttrToken("data-blah"), "Check non existent attr is false"); + ok( $div.hasAttrToken("accesskey", "A"), "Check token is found"); + ok( $div.hasAttrToken("accesskey", "B"), "Check token is found"); + ok( $div.hasAttrToken("accesskey", "C"), "Check token is found"); + ok( !$div.hasAttrToken("accesskey", "a"), "Check token is not found (wrong case)"); + ok( !$div.hasAttrToken("accesskey", "b"), "Check token is not found (wrong case)"); + ok( !$div.hasAttrToken("accesskey", "c"), "Check token is not found (wrong case)"); var $a = jQuery("Hi"); $a.attr("rel", "author nofollow next"); @@ -1193,11 +1193,11 @@ test("hasRel, hasAttrToken", function() { $a2.attr("rel", "author next"); $a.add($a2); - ok( $a.hasRel("author"), "Check rel is found"); - ok( $a.hasRel("nofollow"), "Check rel is found"); - ok( $a.hasRel("next"), "Check rel is found"); - ok( $a.hasRel("AUTHOR"), "Check rel is found (not case sensitive)"); - ok( $a.hasRel("NOFOLLOW"), "Check rel is found (not case sensitive)"); - ok( $a.hasRel("NEXT"), "Check rel is found (not case sensitive)"); - ok( !$a.hasRel("nofollownext"), "Check rel is not found"); + ok( $a.hasAttrToken("rel", "author", true), "Check rel is found"); + ok( $a.hasAttrToken("rel", "nofollow", true), "Check rel is found"); + ok( $a.hasAttrToken("rel", "next", true), "Check rel is found"); + ok( $a.hasAttrToken("rel", "AUTHOR", true), "Check rel is found (not case sensitive)"); + ok( $a.hasAttrToken("rel", "NOFOLLOW", true), "Check rel is found (not case sensitive)"); + ok( $a.hasAttrToken("rel", "NEXT", true), "Check rel is found (not case sensitive)"); + ok( !$a.hasAttrToken("rel", "nofollownext", true), "Check rel is not found"); }); \ No newline at end of file