Skip to content

Commit 0ea342a

Browse files
committed
Manipulation: simplify html wrappers
Take advantage of html serialization for html wrappers - saves 26 bytes Plus add additional test for "col" element Closes gh-2031 Fixes gh-2002
1 parent 45ec73f commit 0ea342a

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

src/manipulation.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,20 @@ var
3333
option: [ 1, "<select multiple='multiple'>", "</select>" ],
3434

3535
thead: [ 1, "<table>", "</table>" ],
36+
37+
// Some of the following wrappers are not fully defined, because
38+
// their parent elements (except for "table" element) could be omitted
39+
// since browser parsers are smart enough to auto-insert them
40+
41+
// Support: Android 2.3
42+
// Android browser doesn't auto-insert colgroup
3643
col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
37-
tr: [ 2, "<table><tbody>", "</tbody></table>" ],
38-
td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
44+
45+
// Auto-insert "tbody" element
46+
tr: [ 2, "<table>", "</table>" ],
47+
48+
// Auto-insert "tbody" and "tr" elements
49+
td: [ 3, "<table>", "</table>" ],
3950

4051
_default: [ 0, "", "" ]
4152
};

test/unit/manipulation.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2452,6 +2452,18 @@ test( "Validate creation of multiple quantities of certain elements (#13818)", 4
24522452
});
24532453
});
24542454

2455+
test( "Make sure col element is appended correctly", function() {
2456+
expect( 1 );
2457+
2458+
var table = jQuery( "<table cellpadding='0'><tr><td>test</td></tr></table>" );
2459+
2460+
jQuery( table ).appendTo( "#qunit-fixture" );
2461+
2462+
jQuery( "<col width='150'/>" ).prependTo( table );
2463+
2464+
strictEqual( table.find( "td" ).width(), 150 );
2465+
});
2466+
24552467
asyncTest( "Insert script with data-URI (gh-1887)", 1, function() {
24562468
Globals.register( "testFoo" );
24572469
Globals.register( "testSrcFoo" );

0 commit comments

Comments
 (0)