From efdb8a46e4213dcf69f792c42c234c6b112ba471 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Mon, 9 Jan 2017 11:37:12 -0800 Subject: Manipulation: Restrict the tbody search to child nodes For performance, use a querySelectorAll path instead of Javascript iteration. http://codepen.io/anon/pen/vywJjx?editors=1010 Fixes gh-3439 Closes gh-3463 --- src/manipulation.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/manipulation.js b/src/manipulation.js index 9b4f5e451..4f79f8998 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -47,11 +47,12 @@ var rscriptTypeMasked = /^true\/(.*)/, rcleanScript = /^\s*\s*$/g; +// Prefer a tbody over its parent table for containing new rows function manipulationTarget( elem, content ) { if ( jQuery.nodeName( elem, "table" ) && jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) { - return elem.getElementsByTagName( "tbody" )[ 0 ] || elem; + return jQuery( ">tbody", elem )[ 0 ] || elem; } return elem; -- cgit v1.2.3