]> source.dussan.org Git - jquery.git/commitdiff
Revert "Manipulation: don't auto-insert tbody"
authorTimmy Willison <timmywillisn@gmail.com>
Wed, 27 Jan 2016 17:19:29 +0000 (12:19 -0500)
committerTimmy Willison <timmywillisn@gmail.com>
Wed, 27 Jan 2016 17:19:41 +0000 (12:19 -0500)
This reverts commit e984d1c79cc476062818e03df04a366baa13d197.

Fixes gh-2861

src/manipulation.js

index b65699bacdabbfe94c86e462ee50de8423af540e..afd5091dda7bdcd74a503b5147f8ee219ca170e8 100644 (file)
@@ -38,14 +38,14 @@ var
        rscriptTypeMasked = /^true\/(.*)/,
        rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/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