From 1df0f9dc8a92f33e8904009221a287bd12cf76d6 Mon Sep 17 00:00:00 2001 From: Adriano Raiano Date: Thu, 22 Apr 2021 12:08:22 +0200 Subject: [PATCH] fix regression for react-i18next, checking void elements should be case sensitive --- src/parse-tag.js | 2 +- test/parse.js | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/parse-tag.js b/src/parse-tag.js index 137d690..570436d 100644 --- a/src/parse-tag.js +++ b/src/parse-tag.js @@ -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 diff --git a/test/parse.js b/test/parse.js index 9a49ab8..1ea26bf 100644 --- a/test/parse.js +++ b/test/parse.js @@ -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 here for more' + 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() }) \ No newline at end of file