Skip to content

Commit 6802263

Browse files
committed
Fix bug when given non-lower-cased types
1 parent d558e6c commit 6802263

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

Diff for: index.js

+4
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,10 @@ function addChild(nodes, value) {
175175
function isNode(tagName, value) {
176176
var type = value.type;
177177

178+
if (typeof type === 'string') {
179+
type = type.toLowerCase();
180+
}
181+
178182
if (tagName === 'input' || !type || typeof type !== 'string') {
179183
return false;
180184
}

Diff for: test.js

+18
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,24 @@ test('hastscript', function (t) {
722722
'a button has a valid type'
723723
);
724724

725+
st.deepEqual(
726+
h('button', {
727+
'type': 'BUTTON',
728+
'value': 'Send'
729+
}),
730+
{
731+
'type': 'element',
732+
'tagName': 'button',
733+
'properties': {
734+
'type': 'BUTTON',
735+
'value': 'Send'
736+
},
737+
'children': []
738+
},
739+
'should *not* allow omitting `properties` when ' +
740+
'a button has a valid non-lowercase type'
741+
);
742+
725743
st.deepEqual(
726744
h('button', {
727745
'type': 'menu',

0 commit comments

Comments
 (0)