Bug Tracker

Ticket #2192: 2192.diff

File 2192.diff, 5.0 KB (added by nathanhammond, 13 years ago)

Patch.

  • jquery/test/unit/selector.js

     
    126126        t( "Nth Child", "p:nth-child(1)", ["firstp","sndp"] );
    127127       
    128128        t( "Last Child", "p:last-child", ["sap"] );
    129         t( "Last Child", "a:last-child", ["simon1","anchor1","mark","yahoo","anchor2","simon"] );
     129        t( "Last Child", "a:last-child", ["simon1","anchor1","mark","yahoo","anchor2","simon","hreflangus", "hreflangcockney", "hreflanguk", "reltest1", "reltest2", "reltest3"] );
    130130       
    131131        t( "Nth-child", "#main form#form > *:nth-child(2)", ["text2"] );
    132132        t( "Nth-child", "#main form#form > :nth-child(2)", ["text2"] );
     
    152152});
    153153
    154154test("attributes", function() {
    155         expect(20);
     155        expect(24);
    156156        t( "Attribute Exists", "a[title]", ["google"] );
    157157        t( "Attribute Exists", "*[title]", ["google"] );
    158158        t( "Attribute Exists", "[title]", ["google"] );
     
    169169        t( "Attribute Begins With", "a[href ^= 'http://www']", ["google","yahoo"] );
    170170        t( "Attribute Ends With", "a[href $= 'org/']", ["mark"] );
    171171        t( "Attribute Contains", "a[href *= 'google']", ["google","groups"] );
     172
     173        t( "Attribute Has Exactly (~=)", "a[rel ~= 'appendix'][rel ~= 'help']", ["reltest2"] );
     174        t( "Attribute Has Exactly (~=)", "a[rel ~= 'section']", ["reltest3"] );
     175        t( "Attribute Begins With (|=)", "a[hreflang |= 'en']", ["mark", "hreflangus", "hreflangcockney", "hreflanguk"] );
     176        t( "Attribute Begins With (|=)", "a[hreflang |= 'en-us']", ["hreflangus"] );
    172177       
    173178        t("Select options via [selected]", "#select1 option[selected]", ["option1a"] );
    174179        t("Select options via [selected]", "#select2 option[selected]", ["option2d"] );
     
    185190        expect(35);
    186191        t( "First Child", "p:first-child", ["firstp","sndp"] );
    187192        t( "Last Child", "p:last-child", ["sap"] );
    188         t( "Only Child", "a:only-child", ["simon1","anchor1","yahoo","anchor2"] );
     193        t( "Only Child", "a:only-child", ["simon1","anchor1","yahoo","anchor2", "hreflangus", "hreflangcockney", "hreflanguk", "reltest1", "reltest2", "reltest3"] );
    189194        t( "Empty", "ul:empty", ["firstUL"] );
    190195        t( "Enabled UI Element", "#form input:enabled", ["text1","radio1","radio2","check1","check2","hidden1","hidden2","name"] );
    191196        t( "Disabled UI Element", "#form input:disabled", ["text2"] );
     
    193198        t( "Selected Option Element", "#form option:selected", ["option1a","option2d","option3b","option3c"] );
    194199        t( "Text Contains", "a:contains('Google')", ["google","groups"] );
    195200        t( "Text Contains", "a:contains('Google Groups')", ["groups"] );
    196         t( "Element Preceded By", "p ~ div", ["foo","fx-queue","fx-tests", "moretests"] );
     201        t( "Element Preceded By", "p ~ div", ["foo","fx-queue","fx-tests", "moretests", "newselectors"] );
    197202        t( "Not", "a.blog:not(.link)", ["mark"] );
    198203        t( "Not - multiple", "#form option:not(:contains('Nothing'),#option1b,:selected)", ["option1c", "option1d", "option2b", "option2c", "option3d", "option3e"] );
    199204        t( "Not - complex", "#form option:not([id^='opt']:gt(0):nth-child(-n+3))", [ "option1a", "option1d", "option2d", "option3d", "option3e"] );
  • jquery/test/index.html

     
    187187                                <div><div class="hidden">hidden</div></div>
    188188                        </div>
    189189                </div>
     190                <div id="newselectors">
     191                        <ul>
     192                                <li><a href="http://example.com/" hreflang="en-us" id="hreflangus">example.com</a></li>
     193                                <li><a href="http://example.com/" hreflang="en-cockney" id="hreflangcockney">example.com</a></li>
     194                                <li><a href="http://example.com/" hreflang="en-uk" id="hreflanguk">example.com</a></li>
     195                                <li><a href="http://example.com/" rel="start next prev contents" id="reltest1">example.com</a></li>
     196                                <li><a href="http://example.com/" rel="appendix help" id="reltest2">example.com</a></li>
     197                                <li><a href="http://example.com/" rel="section" id="reltest3">example.com</a></li>
     198                        </ul>
     199                </div>
    190200        </div>
    191201        </dl>
    192202       
  • jquery/src/selector.js

     
    6868        // The regular expressions that power the parsing engine
    6969        parse: [
    7070                // Match: [@value='test'], [@foo]
    71                 /^(\[) *@?([\w:-]+) *([!*$^~=]*) *('?"?)(.*?)\4 *\]/,
     71                /^(\[) *@?([\w:-]+) *([!*$^~|=]*) *('?"?)(.*?)\4 *\]/,
    7272
    7373                // Match: :contains('foo')
    7474                /^(:)([\w-]+)\("?'?(.*?(\(.*?\))?[^(]*?)"?'?\)/,
     
    344344                                                 type == "!=" && z != m[5] ||
    345345                                                 type == "^=" && z && !z.indexOf(m[5]) ||
    346346                                                 type == "$=" && z.substr(z.length - m[5].length) == m[5] ||
    347                                                  (type == "*=" || type == "~=") && z.indexOf(m[5]) >= 0) ^ not )
     347                                                 type == "*=" && z.indexOf(m[5]) >= 0 ||
     348                                                 type == "~=" && (' '+z+' ').indexOf(' '+m[5]+' ') >= 0 ||
     349                                                 type == "|=" && z.indexOf(m[5]) == 0 && (z.length == m[5].length || z.charAt(m[5].length) == '-')) ^ not )
    348350                                                        tmp.push( a );
    349351                                }
    350352