Skip to content

Commit 084a556

Browse files
committed
Fix to allow non-lowercase tag names
1 parent 6716887 commit 084a556

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

index.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ function element(node, context) {
8787
var parentSchema = context.schema
8888
var schema = parentSchema
8989
var props = node.properties || {}
90-
var name = node.tagName.toLowerCase()
9190
var attributes = []
9291
var children
9392
var info
@@ -96,7 +95,7 @@ function element(node, context) {
9695
var cssProp
9796
var cssProperties
9897

99-
if (parentSchema.space === 'html' && name === 'svg') {
98+
if (parentSchema.space === 'html' && node.tagName.toLowerCase() === 'svg') {
10099
schema = svg
101100
context.schema = schema
102101
}
@@ -129,7 +128,7 @@ function element(node, context) {
129128
}
130129

131130
if (prop === 'style' && typeof value === 'string') {
132-
value = parseStyle(value, name)
131+
value = parseStyle(value, node.tagName)
133132
}
134133

135134
if (value === true) {
@@ -182,7 +181,7 @@ function element(node, context) {
182181
// Restore parent schema.
183182
context.schema = parentSchema
184183

185-
return createJsxElement(node, name, attributes, children)
184+
return createJsxElement(node, node.tagName, attributes, children)
186185
}
187186

188187
function mdxjsEsm(node, context) {

test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,12 @@ test('hast-util-to-estree', function (t) {
273273
'should support an element w/o `children`'
274274
)
275275

276+
t.deepEqual(
277+
toEstree({type: 'element', tagName: 'xYx', properties: {}}),
278+
cleanEstree(ac.parse('<xYx/>')),
279+
'should support an element w/ casing in the `tagName`'
280+
)
281+
276282
t.deepEqual(
277283
toEstree({type: 'element', tagName: 'x', children: []}),
278284
cleanEstree(ac.parse('<x/>')),

0 commit comments

Comments
 (0)