Skip to content

Commit

Permalink
Merge c3d5d5c into 5660b6d
Browse files Browse the repository at this point in the history
  • Loading branch information
GitHub Merge Button committed May 29, 2012
2 parents 5660b6d + c3d5d5c commit 3977148
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/manipulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figca
rleadingWhitespace = /^\s+/,
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
rtagName = /<([\w:]+)/,
rxmlnsName = /xmlns=\"([^\"]*)\"/,
rtbody = /<tbody/i,
rhtml = /<|&#?\w+;/,
rnoInnerhtml = /<(?:script|style|link)/i,
Expand All @@ -40,7 +41,11 @@ var nodeNames = "abbr|article|aside|audio|bdi|canvas|data|datalist|details|figca
area: [ 1, "<map>", "</map>" ],
_default: [ 0, "", "" ]
},
safeFragment = createSafeFragment( document ),
wrapMapNS = {
'http://www.w3.org/2000/svg': [1, "<svg xmlns='http://www.w3.org/2000/svg'>", "</svg>"],
_default: [0, "", ""]
},
safeFragment = createSafeFragment(document),
fragmentDiv = safeFragment.appendChild( document.createElement("div") );

wrapMap.optgroup = wrapMap.option;
Expand Down Expand Up @@ -653,8 +658,10 @@ jQuery.extend({
elem = elem.replace(rxhtmlTag, "<$1></$2>");

// Go to html and back, then peel off extra wrappers
tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase();
wrap = wrapMap[ tag ] || wrapMap._default;
tag = (rtagName.exec(elem) || ["", ""])[1].toLowerCase();
ns = (rxmlnsName.exec(elem.toLowerCase()) || ["", ""])[1].replace(/\/+$/, "");
wrap = wrapMap[tag] || wrapMap._default;
wrap = wrapMapNS[ns] || wrap;
depth = wrap[0];
div.innerHTML = wrap[1] + elem + wrap[2];

Expand Down
6 changes: 6 additions & 0 deletions test/unit/manipulation.js
Original file line number Diff line number Diff line change
Expand Up @@ -1505,6 +1505,12 @@ test("empty()", function() {
equal( j.html(), "", "Check node,textnode,comment empty works" );
});

test("jquery.clean with svg elements (#11827)", function() {
expect(1);
var elem = jQuery['clean'](['<rect xmlns="http://www.w3.org/2000/svg" width="10"></rect>']);
equal( elem[0].width.baseVal.value, 10, "Check if SVG element was created with a valid baseVal for width" );
});

test("jQuery.cleanData", function() {
expect(14);

Expand Down

0 comments on commit 3977148

Please sign in to comment.