Skip to content

Commit 58973ab

Browse files
committed
Remove support for non-nodes
1 parent e996aa9 commit 58973ab

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

lib/index.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,9 @@
1616
*/
1717
export function labelable(node) {
1818
return Boolean(
19-
node &&
20-
typeof node === 'object' &&
21-
node.type === 'element' &&
19+
node.type === 'element' &&
2220
(node.tagName === 'button' ||
23-
(node.tagName === 'input' &&
24-
(node.properties && node.properties.type) !== 'hidden') ||
21+
(node.tagName === 'input' && node.properties.type !== 'hidden') ||
2522
node.tagName === 'keygen' ||
2623
node.tagName === 'meter' ||
2724
node.tagName === 'output' ||

test.js

-5
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ test('labelable', async function (t) {
99
])
1010
})
1111

12-
await t.test('should return `false` without node', async function () {
13-
// @ts-expect-error: check that the runtime supports a missing node.
14-
assert.equal(labelable(), false)
15-
})
16-
1712
await t.test('should return `false` without element', async function () {
1813
assert.equal(labelable({type: 'text', value: 'Alpha'}), false)
1914
})

0 commit comments

Comments
 (0)