jQuery: The Write Less, Do More JavaScript Library

Changeset 4513

Show
Ignore:
Timestamp:
01/23/08 03:54:23 (6 months ago)
Author:
davidserduke
Message:

Fix #2184 by using the jQuery.clean() function instead of a direct innerHTML assignment in the clone() function for IE.

Location:
trunk/jquery
Files:
2 modified

Legend:

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

    r4453 r4513  
    304304                // the name attribute on an input). 
    305305                var clone = this.cloneNode(true), 
    306                     container = document.createElement("div"), 
    307                     container2 = document.createElement("div"); 
     306                    container = document.createElement("div"); 
    308307                container.appendChild(clone); 
    309                 container2.innerHTML = container.innerHTML; 
    310                 return container2.firstChild; 
     308                return jQuery.clean([container.innerHTML])[0]; 
    311309            } else 
    312310                return this.cloneNode(true); 
  • trunk/jquery/test/unit/core.js

    r4449 r4513  
    956956 
    957957test("clone()", function() { 
    958     expect(4); 
     958    expect(20); 
    959959    ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Assert text for #en' ); 
    960960    var clone = $('#yahoo').clone(); 
    961961    ok( 'Try them out:Yahoo' == $('#first').append(clone).text(), 'Check for clone' ); 
    962962    ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Reassert text for #en' ); 
     963 
     964    var cloneTags = [  
     965        "<table/>", "<tr/>", "<td/>", "<div/>",  
     966        "<button/>", "<ul/>", "<ol/>", "<li/>", 
     967        "<input type='checkbox' />", "<select/>", "<option/>", "<textarea/>", 
     968        "<tbody/>", "<thead/>", "<tfoot/>", "<iframe/>" 
     969    ]; 
     970    for (var i = 0; i < cloneTags.length; i++) { 
     971        var j = $(cloneTags[i]); 
     972        equals( j[0].tagName, j.clone()[0].tagName, 'Clone a &lt;' + cloneTags[i].substring(1)); 
     973    } 
     974 
    963975    // using contents will get comments regular, text, and comment nodes 
    964976    var cl = $("#nonnodes").contents().clone();