Skip to content

Commit 5bf852d

Browse files
author
Adam McCrea
committed
Add some basic specs for jQuery.clean()
These tests isolate a bug in IE where unclosed tags will fail to create an element if attributes are present.
1 parent ef9fb80 commit 5bf852d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/unit/manipulation.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,20 @@ test("empty()", function() {
10661066
equals( j.html(), "", "Check node,textnode,comment empty works" );
10671067
});
10681068

1069+
test("jQuery.clean", function() {
1070+
var fragment = document.createDocumentFragment(),
1071+
clean = function(html) { return jQuery.clean( [html], document, fragment, [] )};
1072+
1073+
equals( clean('<div>').length, 1, 'Cleaning a standalone unclosed div element' );
1074+
equals( clean('<div id="foo">').length, 1, 'Cleaning an unclosed div element with attribute' );
1075+
equals( clean('<div id="foo" />').length, 1, 'Cleaning a self-closing div element with attribute' );
1076+
equals( clean('<div id="foo"></div>').length, 1, 'Cleaning a div element with attribute and closing element' );
1077+
equals( clean('<span>').length, 1, 'Cleaning a standalone unclosed span element' );
1078+
equals( clean('<span id="foo">').length, 1, 'Cleaning an unclosed span element with attribute' );
1079+
equals( clean('<span id="foo" />').length, 1, 'Cleaning a self-closing span element with attribute' );
1080+
equals( clean('<span id="foo"></span>').length, 1, 'Cleaning a span element with attribute and closing element' );
1081+
});
1082+
10691083
test("jQuery.cleanData", function() {
10701084
expect(14);
10711085

0 commit comments

Comments
 (0)