1
1
/**
2
- * @typedef {import('hast').Root } Root
3
- * @typedef {import('hast').Content } Content
4
- */
5
-
6
- /**
7
- * @typedef {Root | Content } Node
2
+ * @typedef {import('hast').Nodes } Nodes
8
3
*/
9
4
10
5
import { hasProperty } from 'hast-util-has-property'
@@ -24,7 +19,7 @@ const alwaysInteractive = new Set([
24
19
/**
25
20
* Check if the given value is *interactive content*.
26
21
*
27
- * @param {Node } node
22
+ * @param {Nodes } node
28
23
* Node to check.
29
24
* @returns {boolean }
30
25
* Whether `node` is an `Element` that is classified as *interactive
@@ -41,7 +36,7 @@ const alwaysInteractive = new Set([
41
36
* `select`, and `textarea`
42
37
*/
43
38
export function interactive ( node ) {
44
- if ( ! node || typeof node !== 'object' || node . type !== 'element' ) {
39
+ if ( node . type !== 'element' ) {
45
40
return false
46
41
}
47
42
@@ -53,7 +48,7 @@ export function interactive(node) {
53
48
( name === 'video' && hasProperty ( node , 'controls' ) ) ||
54
49
( name === 'object' && hasProperty ( node , 'useMap' ) ) ||
55
50
( name === 'img' && hasProperty ( node , 'useMap' ) ) ||
56
- ( name === 'input' && ( node . properties || { } ) . type !== 'hidden' ) ||
51
+ ( name === 'input' && node . properties . type !== 'hidden' ) ||
57
52
hasProperty ( node , 'tabIndex' ) ||
58
53
alwaysInteractive . has ( name )
59
54
)
0 commit comments