Fix #12957. Simplify wrapMap, it doesn't need end tags. Close gh-1044.

This commit is contained in:
Oleg
2012-11-27 21:32:59 -05:00
committed by Dave Methvin
parent 1052f9cb2b
commit 9ae6b1a019
3 changed files with 18 additions and 19 deletions

View File

@@ -30,18 +30,18 @@ var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figca
rscriptTypeMasked = /^true\/(.*)/,
rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
wrapMap = {
option: [ 1, "<select multiple='multiple'>", "</select>" ],
legend: [ 1, "<fieldset>", "</fieldset>" ],
area: [ 1, "<map>", "</map>" ],
param: [ 1, "<object>", "</object>" ],
thead: [ 1, "<table>", "</table>" ],
tr: [ 2, "<table><tbody>", "</tbody></table>" ],
col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
option: [ 1, "<select multiple='multiple'>" ],
legend: [ 1, "<fieldset>" ],
area: [ 1, "<map>" ],
param: [ 1, "<object>" ],
thead: [ 1, "<table>" ],
tr: [ 2, "<table><tbody>" ],
col: [ 2, "<table><tbody></tbody><colgroup>", "</table>" ],
td: [ 3, "<table><tbody><tr>" ],
// IE6-8 can't serialize link, script, style, or any html5 (NoScope) tags,
// unless wrapped in a div with non-breaking characters in front of it.
_default: jQuery.support.htmlSerialize ? [ 0, "", "" ] : [ 1, "X<div>", "" ]
_default: jQuery.support.htmlSerialize ? [ 0, "" ] : [ 1, "X<div>" ]
},
safeFragment = createSafeFragment( document ),
fragmentDiv = safeFragment.appendChild( document.createElement("div") );
@@ -713,7 +713,7 @@ jQuery.extend({
// Deserialize a standard representation
tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase();
wrap = wrapMap[ tag ] || wrapMap._default;
tmp.innerHTML = wrap[1] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[2];
tmp.innerHTML = wrap[1] + elem.replace( rxhtmlTag, "<$1></$2>" ) + ( wrap[2] || "" );
// Descend through wrappers to the right content
j = wrap[0];