Skip to content

Commit 9fc377b

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
1 parent e905dcd commit 9fc377b

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

src/manipulation.js

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

3535
thead: [ 1, "<table>", "</table>" ],
36-
col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
37-
tr: [ 2, "<table><tbody>", "</tbody></table>" ],
38-
td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
36+
37+
// 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+
col: [
41+
42+
2,
43+
// Support: Android 2.3
44+
// Android browser doesn't auto-inserts colgroup element
45+
"<table><colgroup>", "</colgroup></table>"
46+
],
47+
48+
tr: [
49+
2, // - auto-inserts "tbody" element
50+
"<table>", "</table>"
51+
],
52+
53+
td: [
54+
3, // - auto-inserts "tbody" and "tr" elements
55+
"<table>", "</table>"
56+
],
3957

4058
_default: [ 0, "", "" ]
4159
};

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)