Bug Tracker

Changeset 4029

Show
Ignore:
Timestamp:
12/05/07 00:26:13 (1 year ago)
Author:
davidserduke
Message:

Fixed #1264. If you read the bug there were many proposed changes. As it turned out most of them had already been implemented. The last ones necessary were in .domManip() with when a <table> was 'this' and for .text(). Adding these last changes seems to make dom and text manipulation in IE frames possible. Unit test cases were added as well.

In addition "submit.gif" was removed from the test suite index.html since it didn't exist.

Location:
trunk/jquery
Files:
1 added
3 modified

Legend:

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

    r4014 r4029  
    203203    text: function( text ) { 
    204204        if ( typeof text != "object" && text != null ) 
    205             return this.empty().append( document.createTextNode( text ) ); 
     205            return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) ); 
    206206 
    207207        var ret = ""; 
     
    469469 
    470470            if ( table && jQuery.nodeName( this, "table" ) && jQuery.nodeName( elems[0], "tr" ) ) 
    471                 obj = this.getElementsByTagName("tbody")[0] || this.appendChild( document.createElement("tbody") ); 
     471                obj = this.getElementsByTagName("tbody")[0] || this.appendChild( this.ownerDocument.createElement("tbody") ); 
    472472 
    473473            var scripts = jQuery( [] ); 
  • trunk/jquery/test/index.html

    r3959 r4029  
    2222    <!-- Test HTML --> 
    2323    <div id="nothiddendiv" style="height:1px;background:white;"></div> 
     24    <!-- this iframe is outside the #main so it won't reload constantly wasting time, but it means the tests must be "safe" and clean up after themselves --> 
     25    <iframe id="loadediframe" name="loadediframe" style="display:none;" src="data/iframe.html"></iframe> 
    2426    <dl id="dl" style="display:none;"> 
    2527    <div id="main" style="display: none;"> 
     
    152154            <input type="submit" name="sub1" value="NO" /> 
    153155            <input type="submit" name="sub2" value="NO" /> 
    154             <input type="image" name="sub3" value="NO" src="submit.gif" /> 
     156            <input type="image" name="sub3" value="NO" /> 
    155157            <button name="sub4" type="submit" value="NO">NO</button> 
    156158            <input name="D1" type="text" value="NO" disabled="disabled" /> 
  • trunk/jquery/test/unit/core.js

    r4014 r4029  
    552552    var pass = true; 
    553553    try { 
    554         $( $("iframe")[0].contentWindow.document.body ).append("<div>test</div>"); 
     554        $( $("#iframe")[0].contentWindow.document.body ).append("<div>test</div>"); 
    555555    } catch(e) { 
    556556        pass = false; 
     
    11891189 
    11901190test("contents()", function() { 
    1191     expect(2); 
     1191    expect(10); 
    11921192    equals( $("#ap").contents().length, 9, "Check element contents" ); 
    11931193    ok( $("#iframe").contents()[0], "Check existance of IFrame document" ); 
    1194     // Disabled, randomly fails 
    1195     //ok( $("#iframe").contents()[0].body, "Check existance of IFrame body" ); 
    1196 }); 
     1194    var ibody = $("#loadediframe").contents()[0].body; 
     1195    ok( ibody, "Check existance of IFrame body" ); 
     1196 
     1197    equals( $("span", ibody).text(), "span text", "Find span in IFrame and check its text" ); 
     1198 
     1199    $(ibody).append("<div>init text</div>"); 
     1200    equals( $("div", ibody).length, 2, "Check the original div and the new div are in IFrame" ); 
     1201 
     1202    equals( $("div:last", ibody).text(), "init text", "Add text to div in IFrame" ); 
     1203 
     1204    $("div:last", ibody).text("div text"); 
     1205    equals( $("div:last", ibody).text(), "div text", "Add text to div in IFrame" ); 
     1206 
     1207    $("div:last", ibody).remove(); 
     1208    equals( $("div", ibody).length, 1, "Delete the div and check only one div left in IFrame" ); 
     1209 
     1210    equals( $("div", ibody).text(), "span text", "Make sure the correct div is still left after deletion in IFrame" ); 
     1211 
     1212    $("<table/>", ibody).append("<tr><td>cell</td></tr>").appendTo(ibody); 
     1213    $("table", ibody).remove(); 
     1214    equals( $("div", ibody).length, 1, "Check for JS error on add and delete of a table in IFrame" ); 
     1215});