From: Oleg Date: Wed, 16 Jan 2013 18:07:53 +0000 (+0400) Subject: Fix #13232, fix jQuery.buildFragment for tables, close gh-1138. X-Git-Tag: 2.0.0b2~76 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=19def21df41d6be6419e4d2480a656d9e1a0e6b7;p=jquery.git Fix #13232, fix jQuery.buildFragment for tables, close gh-1138. --- diff --git a/src/manipulation.js b/src/manipulation.js index 3193ad7af..9a2b3db66 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -15,15 +15,17 @@ var rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^> // Support: IE 9 option: [ 1, "" ], - tr: [ 1, "", "
" ], - td: [ 3, "", "
" ], + thead: [ 1, "", "
" ], + tr: [ 2, "", "
" ], + td: [ 3, "", "
" ], + _default: [ 0, "", "" ] }; // Support: IE 9 wrapMap.optgroup = wrapMap.option; -wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead = wrapMap.col = wrapMap.tr; +wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.col = wrapMap.thead; wrapMap.th = wrapMap.td; jQuery.fn.extend({ diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index c5bee2ca9..fdbae76d7 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -2196,3 +2196,32 @@ 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 specific elements with content created correctly (#13232)", 20, function() { + var results = [], + args = [], + elems = { + thead: "thead", + tbody: "tbody", + tfoot: "tfoot", + colgroup: "", + caption: "caption", + tr: "tr", + th: "th", + td: "
td
", + optgroup: "", + option: "option" + }; + + jQuery.each( elems, function( name, value ) { + var html = "<" + name + ">" + value + ""; + ok( jQuery.nodeName( jQuery.parseHTML( "<" + name + ">" + value + "" )[ 0 ], name ), name + " is created correctly" ); + + results.push( name ); + args.push( html ); + }); + + jQuery.fn.append.apply( jQuery("
"), args ).children().each(function( i ) { + ok( jQuery.nodeName( this, results[ i ] ) ); + }); +});