Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

[WIP] Allow empty attributes #32

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const entityRegex = new RegExp('&[a-z0-9#]+;', 'gi')
// Element for setting innerHTML for transforming entities.
let el = null;

export function unescapeEntities(text, context) {
export function unescapeEntities(text = '', context) {
// Create the element using the context if it doesn't exist.
if (!el) {
el = context.createElement('div');
Expand Down
11 changes: 11 additions & 0 deletions test/tests/strings_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,15 @@ describe("#virtualizeString", () => {
const vnodes = virtualizeString("<span>foo</span> <span>bar</span>");
expect(vnodes.length).to.equal(3)
})

it("should handle attributes with empty value", () => {
const input = virtualizeString("<input readonly />");
expect(input).to.deep.equal(
h('input', {
attrs: {
readonly: ''
}
})
);
});
});