Skip to content

Commit 175be3b

Browse files
Ensuring $.parseHTML always preserves the content of nodes
This was not always the case in IE11
1 parent 3e2f787 commit 175be3b

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/core/parse_html.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// @require ./cash.js
33
// @require ./variables.js
44
// @require ./type_checking.js
5+
// @require collection/get.js
6+
// @require manipulation/detach.js
57

68
let fragment;
79

@@ -17,7 +19,7 @@ function parseHTML ( html ) { //FIXME: `<tr></tr>` can't be parsed with this
1719
initFragment ();
1820
if ( !isString ( html ) ) html = '';
1921
fragment.body.innerHTML = html;
20-
return slice.call ( fragment.body.childNodes );
22+
return $(fragment.body.childNodes).detach ().get ();
2123
}
2224

2325
cash.parseHTML = parseHTML;

test/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,10 @@ QUnit.test( "$.matches", function( assert ) {
835835

836836
QUnit.test( "$.parseHTML", function( assert ) {
837837
assert.equal($.parseHTML('<a></a>')[0].outerHTML, '<a></a>' , "$.parseHTML Passed!" );
838+
839+
var span = $('<span>CONTENT</span>');
840+
$('<div></div>');
841+
assert.equal(span.html(),'CONTENT', '$.parseHTML doesn\'t overwrite the content');
838842
});
839843

840844
QUnit.test( "$.prefixedProp", function( assert ) {

0 commit comments

Comments
 (0)