Skip to content

Commit

Permalink
Manipulation: simplify html wrappers
Browse files Browse the repository at this point in the history
Take advantage of html serialization for html wrappers - saves 26 bytes
Plus add additional test for "col" element

Closes jquerygh-2031
Fixes jquerygh-2002
  • Loading branch information
markelog committed Feb 10, 2015
1 parent 45ec73f commit 0ea342a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/manipulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,20 @@ var
option: [ 1, "<select multiple='multiple'>", "</select>" ],

thead: [ 1, "<table>", "</table>" ],

// Some of the following wrappers are not fully defined, because
// their parent elements (except for "table" element) could be omitted
// since browser parsers are smart enough to auto-insert them

// Support: Android 2.3
// Android browser doesn't auto-insert colgroup
col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
tr: [ 2, "<table><tbody>", "</tbody></table>" ],
td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],

// Auto-insert "tbody" element
tr: [ 2, "<table>", "</table>" ],

// Auto-insert "tbody" and "tr" elements
td: [ 3, "<table>", "</table>" ],

_default: [ 0, "", "" ]
};
Expand Down
12 changes: 12 additions & 0 deletions test/unit/manipulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -2452,6 +2452,18 @@ test( "Validate creation of multiple quantities of certain elements (#13818)", 4
});
});

test( "Make sure col element is appended correctly", function() {
expect( 1 );

var table = jQuery( "<table cellpadding='0'><tr><td>test</td></tr></table>" );

jQuery( table ).appendTo( "#qunit-fixture" );

jQuery( "<col width='150'/>" ).prependTo( table );

strictEqual( table.find( "td" ).width(), 150 );
});

asyncTest( "Insert script with data-URI (gh-1887)", 1, function() {
Globals.register( "testFoo" );
Globals.register( "testSrcFoo" );
Expand Down

0 comments on commit 0ea342a

Please sign in to comment.