From: Timmy Willison Date: Wed, 27 Jan 2016 17:19:29 +0000 (-0500) Subject: Revert "Manipulation: don't auto-insert tbody" X-Git-Tag: 2.2.1~10 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=412c5dfb0d6301dc0b3d7c98325cc9908dd97511;p=jquery.git Revert "Manipulation: don't auto-insert tbody" This reverts commit e984d1c79cc476062818e03df04a366baa13d197. Fixes gh-2861 --- diff --git a/src/manipulation.js b/src/manipulation.js index b65699bac..afd5091dd 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -38,14 +38,14 @@ var rscriptTypeMasked = /^true\/(.*)/, rcleanScript = /^\s*\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