]> source.dussan.org Git - jquery.git/commitdiff
Fix #13232, fix jQuery.buildFragment for tables, close gh-1138.
authorOleg <markelog@gmail.com>
Wed, 16 Jan 2013 18:07:53 +0000 (22:07 +0400)
committerDave Methvin <dave.methvin@gmail.com>
Sun, 20 Jan 2013 23:30:56 +0000 (18:30 -0500)
src/manipulation.js
test/unit/manipulation.js

index 3193ad7af591ffdae3f7b93ca5cebeb2af70f695..9a2b3db66a5a7ee714f272ec46d064ba4a80cbcd 100644 (file)
@@ -15,15 +15,17 @@ var rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>
                // Support: IE 9
                option: [ 1, "<select multiple='multiple'>", "</select>" ],
 
-               tr: [ 1, "<table>", "</table>" ],
-               td: [ 3, "<table><tr>", "</tr></table>" ],
+               thead: [ 1, "<table>", "</table>" ],
+               tr: [ 2, "<table><tbody>", "</tbody></table>" ],
+               td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
+
                _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({
index c5bee2ca9f389221559dd09ae94e6d169dbeba80..fdbae76d7fed16f1949080978f120869a89fbe20 100644 (file)
@@ -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: "<tr><td>thead</td></tr>",
+                       tbody: "<tr><td>tbody</td></tr>",
+                       tfoot: "<tr><td>tfoot</td></tr>",
+                       colgroup: "<col span='5' />",
+                       caption: "caption",
+                       tr: "<td>tr</td>",
+                       th: "th",
+                       td: "<div>td</div>",
+                       optgroup: "<option>optgroup</option>",
+                       option: "option"
+               };
+
+       jQuery.each( elems, function( name, value ) {
+               var html = "<" + name + ">" + value + "</" + name + ">";
+               ok( jQuery.nodeName( jQuery.parseHTML( "<" + name + ">" + value + "</" + name + ">" )[ 0 ], name ), name + " is created correctly" );
+
+               results.push( name );
+               args.push( html );
+       });
+
+       jQuery.fn.append.apply( jQuery("<div/>"), args ).children().each(function( i ) {
+               ok( jQuery.nodeName( this, results[ i ] ) );
+       });
+});