jQuery: The Write Less, Do More JavaScript Library

Changeset 2820

Show
Ignore:
Timestamp:
08/21/07 07:33:52 (1 year ago)
Author:
jeresig
Message:

Added the new :has() selector (Bug #1521)

Location:
trunk/jquery/src/selector
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/jquery/src/selector/selector.js

    r2818 r2820  
    5454            reset: "'reset'==a.type", 
    5555            button: '"button"==a.type||jQuery.nodeName(a,"button")', 
    56             input: "/input|select|textarea|button/i.test(a.nodeName)" 
     56            input: "/input|select|textarea|button/i.test(a.nodeName)", 
     57 
     58            // :has() 
     59            has: "jQuery.find(m[3],a).length" 
    5760        }, 
    5861        "[": "jQuery.find(m[2],a).length" 
  • trunk/jquery/src/selector/selectorTest.js

    r2781 r2820  
    198198 
    199199test("basic xpath", function() { 
    200     expect(16); 
     200    expect(17); 
    201201    ok( jQuery.find("//*").length >= 30, "All Elements (//*)" ); 
    202202    ok( jQuery.find("//div", q("main")[0])[0] = q("foo")[0], "All Relative (#main//div)" ); 
     
    214214    t( "Sibling Axis", "//p/../*", ["firstp","ap","foo","first","firstUL","empty","form","floatTest","iframe","lengthtest","table","fx-queue","fx-tests","sndp","en","sap"] ); 
    215215    t( "Has Children", "//p[a]", ["firstp","ap","en","sap"] ); 
     216    t( "Has Children - :has()", "//p:has(a)", ["firstp","ap","en","sap"] ); 
    216217     
    217218    $("#foo").each(function() {