Skip to content

Commit cb8d1e2

Browse files
test: more tests for nonbooleanattributes
1 parent cefe12d commit cb8d1e2

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,4 +1580,17 @@ describe('sanitizeHtml', function() {
15801580
assert.equal(sanitizeHtml('<a href target="_blank">hello</a>', {
15811581
}), '<a target="_blank">hello</a>');
15821582
});
1583+
it('should not remove non-boolean attributes that are empty when disabled', function() {
1584+
assert.equal(sanitizeHtml('<a href target="_blank">hello</a>', {
1585+
nonBooleanAttributes: []
1586+
}), '<a href target="_blank">hello</a>');
1587+
});
1588+
it('should not remove boolean attributes that are empty', function() {
1589+
assert.equal(sanitizeHtml('<input checked form type="checkbox" />', {
1590+
allowedTags: 'input',
1591+
allowedAttributes: {
1592+
input: [ 'checked', 'form', 'type' ]
1593+
}
1594+
}), '<input checked type="checkbox" />');
1595+
});
15831596
});

0 commit comments

Comments
 (0)