From 939e755163c9c9749fdd39ae9e60de7cb41eeb2c Mon Sep 17 00:00:00 2001 From: Oleg Gaidarenko Date: Wed, 11 Feb 2015 17:07:29 +0300 Subject: Manipulation: don't auto-insert tbody Fixes gh-1835 Closes gh-2021 Ref e984d1c79cc476062818e03df04a366baa13d197 --- test/unit/manipulation.js | 75 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) (limited to 'test/unit') diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index 9ea53b8ab..d9e9e40b3 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -2485,6 +2485,81 @@ test( "Make sure jQuery.fn.remove can work on elements in documentFragment", 1, equal( fragment.childNodes.length, 0, "div element was removed from documentFragment" ); }); +test( "Make sure tr element will be appended to tbody element of table when present", function() { + expect( 1 ); + + var html, + table = document.createElement( "table" ); + + table.appendChild( document.createElement( "tbody" ) ); + document.getElementById( "qunit-fixture" ).appendChild( table ); + + jQuery( table ).append( "test" ); + + // Lowercase and replace spaces to remove possible browser inconsistencies + html = table.innerHTML.toLowerCase().replace( /\s/g, "" ); + + strictEqual( html, "test" ); +}); + +test( "Make sure tr elements will be appended to tbody element of table when present", function() { + expect( 1 ); + + var html, + table = document.createElement( "table" ); + + table.appendChild( document.createElement( "tbody" ) ); + document.getElementById( "qunit-fixture" ).appendChild( table ); + + jQuery( table ).append( "12" ); + + // Lowercase and replace spaces to remove possible browser inconsistencies + html = table.innerHTML.toLowerCase().replace( /\s/g, "" ); + + strictEqual( html, "12" ); +}); + +test( "Make sure tfoot element will not be appended to tbody element of table when present", function() { + expect( 1 ); + + var html, + table = document.createElement( "table" ); + + table.appendChild( document.createElement( "tbody" ) ); + document.getElementById( "qunit-fixture" ).appendChild( table ); + + jQuery( table ).append( "" ); + + // Lowercase and replace spaces to remove possible browser inconsistencies + html = table.innerHTML.toLowerCase().replace( /\s/g, "" ); + + strictEqual( html, "" ); +}); + +test( "Make sure document fragment will be appended to tbody element of table when present", function() { + 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, "" ); + + strictEqual( html, "test" ); +}); + test( "Make sure col element is appended correctly", function() { expect( 1 ); -- cgit v1.2.3