Bug Tracker

Ticket #3178: 3178.diff

File 3178.diff, 1.6 KB (added by nathanhammond, 12 years ago)

Patch for sanity check. Includes patch for Test Suite.

  • jquery/test/unit/core.js

     
    217217        ok( !jQuery("<option>test</option>")[0].selected, "Make sure that options are auto-selected #2050" );
    218218});
    219219
     220test("jQuery(selector, 'html')", function() {
     221        expect(2);
     222        var teststring = '';
     223        for (var i = 0; i < 10000; i++) { teststring += '22222222'; }
     224        var htmlcode = '<div><div id="one">one</div><div id="two">' + teststring + '</div></div>';
     225
     226        equals(jQuery('#one', htmlcode).length, 1, "Verify that a selector matching against an HTML blob matches the correct number of times, #3178");
     227        equals(jQuery('#one', htmlcode).html(), 'one', "Verify that a selector matching against an HTML blob reads correctly, #3178");
     228});
     229
    220230test("jQuery('html', context)", function() {
    221231        expect(1);
    222232
  • jquery/src/core.js

     
    4242                }
    4343                // Handle HTML strings
    4444                if ( typeof selector == "string" ) {
    45                         // Are we dealing with HTML string or an ID?
    46                         var match = quickExpr.exec( selector );
     45                        // Are we dealing with an HTML string or an ID?
     46                        // If selector.length is > 49996, Safari chokes (#3178).
     47                        // Assume that anything near that length is HTML.
     48                        var match = selector.length > 40000 ? { 1: selector } : quickExpr.exec( selector );
    4749
    4850                        // Verify a match, and that no context was specified for #id
    4951                        if ( match && (match[1] || !context) ) {