Bug Tracker

Changeset 4014

Show
Ignore:
Timestamp:
12/04/07 19:37:03 (1 year ago)
Author:
davidserduke
Message:

Fixed #1763 by checking to see if .createElement() is available on the context and if isn't default to other contexts.

Location:
trunk/jquery
Files:
2 modified

Legend:

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

    r4013 r4014  
    918918        var ret = []; 
    919919        context = context || document; 
     920        if (!context.createElement)  
     921            context = context.ownerDocument || context[0] && context[0].ownerDocument || document; 
    920922 
    921923        jQuery.each(elems, function(i, elem){ 
  • trunk/jquery/test/unit/core.js

    r4013 r4014  
    1313 
    1414test("$()", function() { 
    15     expect(5); 
     15    expect(4); 
    1616     
    1717    var main = $("#main"); 
    1818    isSet( $("div p", main).get(), q("sndp", "en", "sap"), "Basic selector with jQuery object as context" ); 
    1919     
     20/* 
     21    // disabled since this test was doing nothing. i tried to fix it but i'm not sure 
     22    // what the expected behavior should even be. FF returns "\n" for the text node 
    2023    // make sure this is handled 
    21     $('<p>\r\n</p>'); 
    22     ok( true, "Check for \\r and \\n in jQuery()" ); 
     24    var crlfContainer = $('<p>\r\n</p>'); 
     25    var x = crlfContainer.contents().get(0).nodeValue; 
     26    equals( x, what???, "Check for \\r and \\n in jQuery()" ); 
     27*/ 
    2328     
    2429    /* // Disabled until we add this functionality in 
     
    149154test("$('html')", function() { 
    150155    expect(4); 
    151      
     156 
    152157    reset(); 
    153158    foo = false; 
     
    162167     
    163168    reset(); 
     169}); 
     170 
     171test("$('html', context)", function() { 
     172    expect(1); 
     173 
     174    var $div = $("<div/>"); 
     175    var $span = $("<span/>", $div); 
     176    equals($span.length, 1, "Verify a span created with a div context works"); 
    164177}); 
    165178