Skip to content

Commit

Permalink
Merge pull request #47 from i18next/master
Browse files Browse the repository at this point in the history
checking void elements should be case sensitive
  • Loading branch information
HenrikJoreteg authored Apr 28, 2021
2 parents d1f2a0f + 1df0f9d commit 4261609
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parse-tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function stringify(tag) {
if (tagMatch) {
res.name = tagMatch[1]
if (
lookup[tagMatch[1].toLowerCase()] ||
lookup[tagMatch[1]] ||
tag.charAt(tag.length - 2) === '/'
) {
res.voidElement = true
Expand Down
36 changes: 36 additions & 0 deletions test/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -934,5 +934,41 @@ test('whitespace', function (t) {
}], 'should collapse whitespace')
// See https://www.w3.org/TR/html4/struct/text.html#h-9.1

t.end()
})

test('uppercase tags', function (t) {
const html = '<0>click <Link>here</Link> for more</0>'
const parsed = HTML.parse(html)
t.deepEqual(parsed, [
{
"type": "tag",
"name": "0",
"voidElement": false,
"attrs": {},
"children": [
{
"type": "text",
"content": "click "
},
{
"type": "tag",
"name": "Link",
"voidElement": false,
"attrs": {},
"children": [
{
"type": "text",
"content": "here"
}
]
},
{
"type": "text",
"content": " for more"
}
]
}
], 'should handle uppercase tags correctly')
t.end()
})

0 comments on commit 4261609

Please sign in to comment.