1
- # hast-util-is-element [ ![ Build ] [ build-badge ]] [ build ] [ ![ Coverage ] [ coverage-badge ]] [ coverage ] [ ![ Downloads ] [ downloads-badge ]] [ downloads ] [ ![ Chat ] [ chat-badge ]] [ chat ]
1
+ # hast-util-is-element
2
2
3
- Check if a [ node] [ ] is a (certain) [ ** HAST** ] [ hast ] [ element] [ ] .
3
+ [ ![ Build] [ build-badge ]] [ build ]
4
+ [ ![ Coverage] [ coverage-badge ]] [ coverage ]
5
+ [ ![ Downloads] [ downloads-badge ]] [ downloads ]
6
+ [ ![ Size] [ size-badge ]] [ size ]
7
+ [ ![ Sponsors] [ sponsors-badge ]] [ collective ]
8
+ [ ![ Backers] [ backers-badge ]] [ collective ]
9
+ [ ![ Chat] [ chat-badge ]] [ chat ]
4
10
5
- ## Installation
11
+ [ ** hast** ] [ hast ] utility to check if a [ * node* ] [ node ] is a (certain)
12
+ [ * element* ] [ element ] .
13
+
14
+ ## Install
6
15
7
16
[ npm] [ ] :
8
17
9
- ``` bash
18
+ ``` sh
10
19
npm install hast-util-is-element
11
20
```
12
21
13
22
## Usage
14
23
15
- ``` javascript
24
+ ``` js
16
25
var is = require (' hast-util-is-element' )
17
26
18
27
is ({type: ' text' , value: ' foo' }) // => false
@@ -26,17 +35,20 @@ is({type: 'element', tagName: 'a'}, ['a', 'area']) // => true
26
35
27
36
### ` isElement(node[, tagName|tagNames]) `
28
37
29
- Check if a [ node ] [ ] is a (certain) [ ** HAST ** ] [ hast ] [ element] [ ] .
38
+ Check if the given value is a (certain) [ * element * ] [ element ] .
30
39
31
- When not given a second parameter, asserts if ` node ` is an element,
32
- otherwise asserts ` node ` is an element whose ` tagName ` matches / is
33
- included in the second parameter.
40
+ * When given a ` tagName ` or ` tagNames ` , checks that ` node ` is an
41
+ [ * element* ] [ element ] whose ` tagName ` field matches ` tagName ` or is included
42
+ in ` tagNames `
43
+ * Otherwise checks that ` node ` is an [ * element* ] [ element ]
34
44
35
45
###### Parameters
36
46
37
- * ` node ` (` * ` ) — Value to check;
38
- * ` tagName ` (` string ` , optional) — Value ` node ` s ` tagName ` must match;
39
- * ` tagNames ` (` Array.<string> ` , optional) — Value including ` node ` s ` tagName ` .
47
+ * ` node ` (` * ` ) — Value to check, probably [ ` Node ` ] [ node ]
48
+ * ` tagName ` (` string ` , optional) — Value that ` node ` s ` tagName ` field should
49
+ match
50
+ * ` tagNames ` (` Array.<string> ` , optional) — Values that should include ` node ` s
51
+ ` tagName ` field should match
40
52
41
53
###### Returns
42
54
@@ -48,11 +60,13 @@ included in the second parameter.
48
60
49
61
## Contribute
50
62
51
- See [ ` contributing.md ` in ` syntax-tree/hast ` ] [ contributing ] for ways to get
63
+ See [ ` contributing.md ` in ` syntax-tree/.github ` ] [ contributing ] for ways to get
52
64
started.
65
+ See [ ` support.md ` ] [ support ] for ways to get help.
53
66
54
- This organisation has a [ Code of Conduct] [ coc ] . By interacting with this
55
- repository, organisation, or community you agree to abide by its terms.
67
+ This project has a [ Code of Conduct] [ coc ] .
68
+ By interacting with this repository, organisation, or community you agree to
69
+ abide by its terms.
56
70
57
71
## License
58
72
@@ -72,22 +86,34 @@ repository, organisation, or community you agree to abide by its terms.
72
86
73
87
[ downloads ] : https://www.npmjs.com/package/hast-util-is-element
74
88
89
+ [ size-badge ] : https://img.shields.io/bundlephobia/minzip/hast-util-is-element.svg
90
+
91
+ [ size ] : https://bundlephobia.com/result?p=hast-util-is-element
92
+
93
+ [ sponsors-badge ] : https://opencollective.com/unified/sponsors/badge.svg
94
+
95
+ [ backers-badge ] : https://opencollective.com/unified/backers/badge.svg
96
+
97
+ [ collective ] : https://opencollective.com/unified
98
+
75
99
[ chat-badge ] : https://img.shields.io/badge/join%20the%20community-on%20spectrum-7b16ff.svg
76
100
77
- [ chat ] : https://spectrum.chat/unified/rehype
101
+ [ chat ] : https://spectrum.chat/unified/syntax-tree
78
102
79
103
[ npm ] : https://docs.npmjs.com/cli/install
80
104
81
105
[ license ] : license
82
106
83
107
[ author ] : https://wooorm.com
84
108
109
+ [ contributing ] : https://github.com/syntax-tree/.github/blob/master/contributing.md
110
+
111
+ [ support ] : https://github.com/syntax-tree/.github/blob/master/support.md
112
+
113
+ [ coc ] : https://github.com/syntax-tree/.github/blob/master/code-of-conduct.md
114
+
85
115
[ hast ] : https://github.com/syntax-tree/hast
86
116
87
117
[ node ] : https://github.com/syntax-tree/unist#node
88
118
89
119
[ element ] : https://github.com/syntax-tree/hast#element
90
-
91
- [ contributing ] : https://github.com/syntax-tree/hast/blob/master/contributing.md
92
-
93
- [ coc ] : https://github.com/syntax-tree/hast/blob/master/code-of-conduct.md
0 commit comments