Revert "Manipulation: don't auto-insert tbody"

This reverts commit 939e755163.
This commit is contained in:
Oleg Gaidarenko 2015-12-22 17:15:18 +03:00
parent c999b6613e
commit 47c0aac67f
2 changed files with 8 additions and 84 deletions

View File

@ -46,13 +46,12 @@ var rinlinejQuery = / jQuery\d+="(?:null|\d+)"/g,
// Manipulating tables requires a tbody
function manipulationTarget( elem, content ) {
if ( jQuery.nodeName( elem, "table" ) &&
jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
return jQuery.nodeName( elem, "table" ) &&
jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ?
return elem.getElementsByTagName( "tbody" )[ 0 ] || elem;
}
return elem;
elem.getElementsByTagName("tbody")[0] ||
elem.appendChild( elem.ownerDocument.createElement("tbody") ) :
elem;
}
// Replace/restore the type attribute of script elements for safe DOM manipulation

View File

@ -2596,83 +2596,8 @@ QUnit.test( "Make sure jQuery.fn.remove can work on elements in documentFragment
assert.equal( fragment.childNodes.length, 0, "div element was removed from documentFragment" );
} );
QUnit.test( "Make sure tr element will be appended to tbody element of table when present", function( assert ) {
assert.expect( 1 );
var html,
table = document.createElement( "table" );
table.appendChild( document.createElement( "tbody" ) );
document.getElementById( "qunit-fixture" ).appendChild( table );
jQuery( table ).append( "<tr><td>test</td></tr>" );
// Lowercase and replace spaces to remove possible browser inconsistencies
html = table.innerHTML.toLowerCase().replace( /\s/g, "" );
assert.strictEqual( html, "<tbody><tr><td>test</td></tr></tbody>" );
} );
QUnit.test( "Make sure tr elements will be appended to tbody element of table when present", function( assert ) {
assert.expect( 1 );
var html,
table = document.createElement( "table" );
table.appendChild( document.createElement( "tbody" ) );
document.getElementById( "qunit-fixture" ).appendChild( table );
jQuery( table ).append( "<tr><td>1</td></tr><tr><td>2</td></tr>" );
// Lowercase and replace spaces to remove possible browser inconsistencies
html = table.innerHTML.toLowerCase().replace( /\s/g, "" );
assert.strictEqual( html, "<tbody><tr><td>1</td></tr><tr><td>2</td></tr></tbody>" );
} );
QUnit.test( "Make sure tfoot element will not be appended to tbody element of table when present", function( assert ) {
assert.expect( 1 );
var html,
table = document.createElement( "table" );
table.appendChild( document.createElement( "tbody" ) );
document.getElementById( "qunit-fixture" ).appendChild( table );
jQuery( table ).append( "<tfoot/>" );
// Lowercase and replace spaces to remove possible browser inconsistencies
html = table.innerHTML.toLowerCase().replace( /\s/g, "" );
assert.strictEqual( html, "<tbody></tbody><tfoot></tfoot>" );
} );
QUnit.test( "Make sure document fragment will be appended to tbody element of table when present", function( assert ) {
assert.expect( 1 );
var html,
fragment = document.createDocumentFragment(),
table = document.createElement( "table" ),
tr = document.createElement( "tr" ),
td = document.createElement( "td" );
table.appendChild( document.createElement( "tbody" ) );
document.getElementById( "qunit-fixture" ).appendChild( table );
fragment.appendChild( tr );
tr.appendChild( td );
td.innerHTML = "test";
jQuery( table ).append( fragment );
// Lowercase and replace spaces to remove possible browser inconsistencies
html = table.innerHTML.toLowerCase().replace( /\s/g, "" );
assert.strictEqual( html, "<tbody><tr><td>test</td></tr></tbody>" );
} );
QUnit.test( "Make sure col element is appended correctly", function( assert ) {
assert.expect( 1 );
test( "Make sure col element is appended correctly", function() {
expect( 1 );
var table = jQuery( "<table cellpadding='0'><tr><td style='padding:0'>test</td></tr></table>" );
@ -2680,7 +2605,7 @@ QUnit.test( "Make sure col element is appended correctly", function( assert ) {
jQuery( "<col width='150'/>" ).prependTo( table );
assert.strictEqual( table.find( "td" ).width(), 150 );
strictEqual( table.find( "td" ).width(), 150 );
} );
QUnit.asyncTest( "Insert script with data-URI (gh-1887)", 1, function( assert ) {