aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit
diff options
context:
space:
mode:
authorOleg Gaidarenko <markelog@gmail.com>2015-02-11 17:07:29 +0300
committerOleg Gaidarenko <markelog@gmail.com>2015-02-11 17:11:15 +0300
commit939e755163c9c9749fdd39ae9e60de7cb41eeb2c (patch)
tree1a57301f0b8ee17f353e75c503c1f0e299c197c2 /test/unit
parentb744a50d472664a4d5aaa35d58e2215d48f70d3b (diff)
downloadjquery-939e755163c9c9749fdd39ae9e60de7cb41eeb2c.tar.gz
jquery-939e755163c9c9749fdd39ae9e60de7cb41eeb2c.zip
Manipulation: don't auto-insert tbody
Fixes gh-1835 Closes gh-2021 Ref e984d1c79cc476062818e03df04a366baa13d197
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/manipulation.js75
1 files changed, 75 insertions, 0 deletions
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( "<tr><td>test</td></tr>" );
+
+ // Lowercase and replace spaces to remove possible browser inconsistencies
+ html = table.innerHTML.toLowerCase().replace( /\s/g, "" );
+
+ strictEqual( html, "<tbody><tr><td>test</td></tr></tbody>" );
+});
+
+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( "<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, "" );
+
+ strictEqual( html, "<tbody><tr><td>1</td></tr><tr><td>2</td></tr></tbody>" );
+});
+
+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( "<tfoot/>" );
+
+ // Lowercase and replace spaces to remove possible browser inconsistencies
+ html = table.innerHTML.toLowerCase().replace( /\s/g, "" );
+
+ strictEqual( html, "<tbody></tbody><tfoot></tfoot>" );
+});
+
+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, "<tbody><tr><td>test</td></tr></tbody>" );
+});
+
test( "Make sure col element is appended correctly", function() {
expect( 1 );