@depup/cheerio 1.2.0-depup.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (230) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +36 -0
  3. package/Readme.md +229 -0
  4. package/changes.json +30 -0
  5. package/dist/browser/api/attributes.d.ts +385 -0
  6. package/dist/browser/api/attributes.d.ts.map +1 -0
  7. package/dist/browser/api/attributes.js +636 -0
  8. package/dist/browser/api/attributes.js.map +1 -0
  9. package/dist/browser/api/css.d.ts +42 -0
  10. package/dist/browser/api/css.d.ts.map +1 -0
  11. package/dist/browser/api/css.js +116 -0
  12. package/dist/browser/api/css.js.map +1 -0
  13. package/dist/browser/api/extract.d.ts +27 -0
  14. package/dist/browser/api/extract.d.ts.map +1 -0
  15. package/dist/browser/api/extract.js +42 -0
  16. package/dist/browser/api/extract.js.map +1 -0
  17. package/dist/browser/api/forms.d.ts +36 -0
  18. package/dist/browser/api/forms.d.ts.map +1 -0
  19. package/dist/browser/api/forms.js +81 -0
  20. package/dist/browser/api/forms.js.map +1 -0
  21. package/dist/browser/api/manipulation.d.ts +528 -0
  22. package/dist/browser/api/manipulation.d.ts.map +1 -0
  23. package/dist/browser/api/manipulation.js +831 -0
  24. package/dist/browser/api/manipulation.js.map +1 -0
  25. package/dist/browser/api/traversing.d.ts +657 -0
  26. package/dist/browser/api/traversing.d.ts.map +1 -0
  27. package/dist/browser/api/traversing.js +857 -0
  28. package/dist/browser/api/traversing.js.map +1 -0
  29. package/dist/browser/cheerio.d.ts +85 -0
  30. package/dist/browser/cheerio.d.ts.map +1 -0
  31. package/dist/browser/cheerio.js +58 -0
  32. package/dist/browser/cheerio.js.map +1 -0
  33. package/dist/browser/index-browser.d.mts.map +1 -0
  34. package/dist/browser/index-browser.mjs.map +1 -0
  35. package/dist/browser/index.d.ts +5 -0
  36. package/dist/browser/index.js +3 -0
  37. package/dist/browser/load-parse.d.ts +20 -0
  38. package/dist/browser/load-parse.d.ts.map +1 -0
  39. package/dist/browser/load-parse.js +28 -0
  40. package/dist/browser/load-parse.js.map +1 -0
  41. package/dist/browser/load.d.ts +91 -0
  42. package/dist/browser/load.d.ts.map +1 -0
  43. package/dist/browser/load.js +129 -0
  44. package/dist/browser/load.js.map +1 -0
  45. package/dist/browser/options.d.ts +98 -0
  46. package/dist/browser/options.d.ts.map +1 -0
  47. package/dist/browser/options.js +34 -0
  48. package/dist/browser/options.js.map +1 -0
  49. package/dist/browser/package.json +3 -0
  50. package/dist/browser/parse.d.ts +18 -0
  51. package/dist/browser/parse.d.ts.map +1 -0
  52. package/dist/browser/parse.js +73 -0
  53. package/dist/browser/parse.js.map +1 -0
  54. package/dist/browser/parsers/parse5-adapter.d.ts +20 -0
  55. package/dist/browser/parsers/parse5-adapter.d.ts.map +1 -0
  56. package/dist/browser/parsers/parse5-adapter.js +50 -0
  57. package/dist/browser/parsers/parse5-adapter.js.map +1 -0
  58. package/dist/browser/slim.d.ts +25 -0
  59. package/dist/browser/slim.d.ts.map +1 -0
  60. package/dist/browser/slim.js +22 -0
  61. package/dist/browser/slim.js.map +1 -0
  62. package/dist/browser/static.d.ts +112 -0
  63. package/dist/browser/static.d.ts.map +1 -0
  64. package/dist/browser/static.js +204 -0
  65. package/dist/browser/static.js.map +1 -0
  66. package/dist/browser/types.d.ts +21 -0
  67. package/dist/browser/types.d.ts.map +1 -0
  68. package/dist/browser/types.js +3 -0
  69. package/dist/browser/types.js.map +1 -0
  70. package/dist/browser/utils.d.ts +55 -0
  71. package/dist/browser/utils.d.ts.map +1 -0
  72. package/dist/browser/utils.js +84 -0
  73. package/dist/browser/utils.js.map +1 -0
  74. package/dist/commonjs/api/attributes.d.ts +385 -0
  75. package/dist/commonjs/api/attributes.d.ts.map +1 -0
  76. package/dist/commonjs/api/attributes.js +647 -0
  77. package/dist/commonjs/api/attributes.js.map +1 -0
  78. package/dist/commonjs/api/css.d.ts +42 -0
  79. package/dist/commonjs/api/css.d.ts.map +1 -0
  80. package/dist/commonjs/api/css.js +119 -0
  81. package/dist/commonjs/api/css.js.map +1 -0
  82. package/dist/commonjs/api/extract.d.ts +27 -0
  83. package/dist/commonjs/api/extract.d.ts.map +1 -0
  84. package/dist/commonjs/api/extract.js +45 -0
  85. package/dist/commonjs/api/extract.js.map +1 -0
  86. package/dist/commonjs/api/forms.d.ts +36 -0
  87. package/dist/commonjs/api/forms.d.ts.map +1 -0
  88. package/dist/commonjs/api/forms.js +85 -0
  89. package/dist/commonjs/api/forms.js.map +1 -0
  90. package/dist/commonjs/api/manipulation.d.ts +528 -0
  91. package/dist/commonjs/api/manipulation.d.ts.map +1 -0
  92. package/dist/commonjs/api/manipulation.js +850 -0
  93. package/dist/commonjs/api/manipulation.js.map +1 -0
  94. package/dist/commonjs/api/traversing.d.ts +657 -0
  95. package/dist/commonjs/api/traversing.d.ts.map +1 -0
  96. package/dist/commonjs/api/traversing.js +914 -0
  97. package/dist/commonjs/api/traversing.js.map +1 -0
  98. package/dist/commonjs/cheerio.d.ts +85 -0
  99. package/dist/commonjs/cheerio.d.ts.map +1 -0
  100. package/dist/commonjs/cheerio.js +95 -0
  101. package/dist/commonjs/cheerio.js.map +1 -0
  102. package/dist/commonjs/index.d.ts +104 -0
  103. package/dist/commonjs/index.d.ts.map +1 -0
  104. package/dist/commonjs/index.js +250 -0
  105. package/dist/commonjs/index.js.map +1 -0
  106. package/dist/commonjs/load-parse.d.ts +20 -0
  107. package/dist/commonjs/load-parse.d.ts.map +1 -0
  108. package/dist/commonjs/load-parse.js +34 -0
  109. package/dist/commonjs/load-parse.js.map +1 -0
  110. package/dist/commonjs/load.d.ts +91 -0
  111. package/dist/commonjs/load.d.ts.map +1 -0
  112. package/dist/commonjs/load.js +165 -0
  113. package/dist/commonjs/load.js.map +1 -0
  114. package/dist/commonjs/options.d.ts +98 -0
  115. package/dist/commonjs/options.d.ts.map +1 -0
  116. package/dist/commonjs/options.js +37 -0
  117. package/dist/commonjs/options.js.map +1 -0
  118. package/dist/commonjs/package.json +3 -0
  119. package/dist/commonjs/parse.d.ts +18 -0
  120. package/dist/commonjs/parse.d.ts.map +1 -0
  121. package/dist/commonjs/parse.js +77 -0
  122. package/dist/commonjs/parse.js.map +1 -0
  123. package/dist/commonjs/parsers/parse5-adapter.d.ts +20 -0
  124. package/dist/commonjs/parsers/parse5-adapter.d.ts.map +1 -0
  125. package/dist/commonjs/parsers/parse5-adapter.js +54 -0
  126. package/dist/commonjs/parsers/parse5-adapter.js.map +1 -0
  127. package/dist/commonjs/slim.d.ts +25 -0
  128. package/dist/commonjs/slim.d.ts.map +1 -0
  129. package/dist/commonjs/slim.js +30 -0
  130. package/dist/commonjs/slim.js.map +1 -0
  131. package/dist/commonjs/static.d.ts +112 -0
  132. package/dist/commonjs/static.d.ts.map +1 -0
  133. package/dist/commonjs/static.js +214 -0
  134. package/dist/commonjs/static.js.map +1 -0
  135. package/dist/commonjs/types.d.ts +21 -0
  136. package/dist/commonjs/types.d.ts.map +1 -0
  137. package/dist/commonjs/types.js +4 -0
  138. package/dist/commonjs/types.js.map +1 -0
  139. package/dist/commonjs/utils.d.ts +55 -0
  140. package/dist/commonjs/utils.d.ts.map +1 -0
  141. package/dist/commonjs/utils.js +91 -0
  142. package/dist/commonjs/utils.js.map +1 -0
  143. package/dist/esm/api/attributes.d.ts +385 -0
  144. package/dist/esm/api/attributes.d.ts.map +1 -0
  145. package/dist/esm/api/attributes.js +636 -0
  146. package/dist/esm/api/attributes.js.map +1 -0
  147. package/dist/esm/api/css.d.ts +42 -0
  148. package/dist/esm/api/css.d.ts.map +1 -0
  149. package/dist/esm/api/css.js +116 -0
  150. package/dist/esm/api/css.js.map +1 -0
  151. package/dist/esm/api/extract.d.ts +27 -0
  152. package/dist/esm/api/extract.d.ts.map +1 -0
  153. package/dist/esm/api/extract.js +42 -0
  154. package/dist/esm/api/extract.js.map +1 -0
  155. package/dist/esm/api/forms.d.ts +36 -0
  156. package/dist/esm/api/forms.d.ts.map +1 -0
  157. package/dist/esm/api/forms.js +81 -0
  158. package/dist/esm/api/forms.js.map +1 -0
  159. package/dist/esm/api/manipulation.d.ts +528 -0
  160. package/dist/esm/api/manipulation.d.ts.map +1 -0
  161. package/dist/esm/api/manipulation.js +831 -0
  162. package/dist/esm/api/manipulation.js.map +1 -0
  163. package/dist/esm/api/traversing.d.ts +657 -0
  164. package/dist/esm/api/traversing.d.ts.map +1 -0
  165. package/dist/esm/api/traversing.js +857 -0
  166. package/dist/esm/api/traversing.js.map +1 -0
  167. package/dist/esm/cheerio.d.ts +85 -0
  168. package/dist/esm/cheerio.d.ts.map +1 -0
  169. package/dist/esm/cheerio.js +58 -0
  170. package/dist/esm/cheerio.js.map +1 -0
  171. package/dist/esm/index.d.ts +104 -0
  172. package/dist/esm/index.d.ts.map +1 -0
  173. package/dist/esm/index.js +202 -0
  174. package/dist/esm/index.js.map +1 -0
  175. package/dist/esm/load-parse.d.ts +20 -0
  176. package/dist/esm/load-parse.d.ts.map +1 -0
  177. package/dist/esm/load-parse.js +28 -0
  178. package/dist/esm/load-parse.js.map +1 -0
  179. package/dist/esm/load.d.ts +91 -0
  180. package/dist/esm/load.d.ts.map +1 -0
  181. package/dist/esm/load.js +129 -0
  182. package/dist/esm/load.js.map +1 -0
  183. package/dist/esm/options.d.ts +98 -0
  184. package/dist/esm/options.d.ts.map +1 -0
  185. package/dist/esm/options.js +34 -0
  186. package/dist/esm/options.js.map +1 -0
  187. package/dist/esm/package.json +3 -0
  188. package/dist/esm/parse.d.ts +18 -0
  189. package/dist/esm/parse.d.ts.map +1 -0
  190. package/dist/esm/parse.js +73 -0
  191. package/dist/esm/parse.js.map +1 -0
  192. package/dist/esm/parsers/parse5-adapter.d.ts +20 -0
  193. package/dist/esm/parsers/parse5-adapter.d.ts.map +1 -0
  194. package/dist/esm/parsers/parse5-adapter.js +50 -0
  195. package/dist/esm/parsers/parse5-adapter.js.map +1 -0
  196. package/dist/esm/slim.d.ts +25 -0
  197. package/dist/esm/slim.d.ts.map +1 -0
  198. package/dist/esm/slim.js +22 -0
  199. package/dist/esm/slim.js.map +1 -0
  200. package/dist/esm/static.d.ts +112 -0
  201. package/dist/esm/static.d.ts.map +1 -0
  202. package/dist/esm/static.js +204 -0
  203. package/dist/esm/static.js.map +1 -0
  204. package/dist/esm/types.d.ts +21 -0
  205. package/dist/esm/types.d.ts.map +1 -0
  206. package/dist/esm/types.js +3 -0
  207. package/dist/esm/types.js.map +1 -0
  208. package/dist/esm/utils.d.ts +55 -0
  209. package/dist/esm/utils.d.ts.map +1 -0
  210. package/dist/esm/utils.js +84 -0
  211. package/dist/esm/utils.js.map +1 -0
  212. package/package.json +219 -0
  213. package/src/api/attributes.ts +1145 -0
  214. package/src/api/css.ts +224 -0
  215. package/src/api/extract.ts +92 -0
  216. package/src/api/forms.ts +103 -0
  217. package/src/api/manipulation.ts +1115 -0
  218. package/src/api/traversing.ts +1175 -0
  219. package/src/cheerio.ts +143 -0
  220. package/src/index-browser.mts +10 -0
  221. package/src/index.ts +294 -0
  222. package/src/load-parse.ts +39 -0
  223. package/src/load.ts +282 -0
  224. package/src/options.ts +136 -0
  225. package/src/parse.ts +105 -0
  226. package/src/parsers/parse5-adapter.ts +66 -0
  227. package/src/slim.ts +33 -0
  228. package/src/static.ts +312 -0
  229. package/src/types.ts +58 -0
  230. package/src/utils.ts +99 -0
@@ -0,0 +1,385 @@
1
+ /**
2
+ * Methods for getting and modifying attributes.
3
+ *
4
+ * @module cheerio/attributes
5
+ */
6
+ import { type AnyNode, type Element } from 'domhandler';
7
+ import type { Cheerio } from '../cheerio.js';
8
+ /**
9
+ * Method for getting attributes. Gets the attribute value for only the first
10
+ * element in the matched set.
11
+ *
12
+ * @category Attributes
13
+ * @example
14
+ *
15
+ * ```js
16
+ * $('ul').attr('id');
17
+ * //=> fruits
18
+ * ```
19
+ *
20
+ * @param name - Name of the attribute.
21
+ * @returns The attribute's value.
22
+ * @see {@link https://api.jquery.com/attr/}
23
+ */
24
+ export declare function attr<T extends AnyNode>(this: Cheerio<T>, name: string): string | undefined;
25
+ /**
26
+ * Method for getting all attributes and their values of the first element in
27
+ * the matched set.
28
+ *
29
+ * @category Attributes
30
+ * @example
31
+ *
32
+ * ```js
33
+ * $('ul').attr();
34
+ * //=> { id: 'fruits' }
35
+ * ```
36
+ *
37
+ * @returns The attribute's values.
38
+ * @see {@link https://api.jquery.com/attr/}
39
+ */
40
+ export declare function attr<T extends AnyNode>(this: Cheerio<T>): Record<string, string> | undefined;
41
+ /**
42
+ * Method for setting attributes. Sets the attribute value for all elements in
43
+ * the matched set. If you set an attribute's value to `null`, you remove that
44
+ * attribute. You may also pass a `map` and `function`.
45
+ *
46
+ * @category Attributes
47
+ * @example
48
+ *
49
+ * ```js
50
+ * $('.apple').attr('id', 'favorite').prop('outerHTML');
51
+ * //=> <li class="apple" id="favorite">Apple</li>
52
+ * ```
53
+ *
54
+ * @param name - Name of the attribute.
55
+ * @param value - The new value of the attribute.
56
+ * @returns The instance itself.
57
+ * @see {@link https://api.jquery.com/attr/}
58
+ */
59
+ export declare function attr<T extends AnyNode>(this: Cheerio<T>, name: string, value?: string | null | ((this: Element, i: number, attrib: string) => string | null)): Cheerio<T>;
60
+ /**
61
+ * Method for setting multiple attributes at once. Sets the attribute value for
62
+ * all elements in the matched set. If you set an attribute's value to `null`,
63
+ * you remove that attribute.
64
+ *
65
+ * @category Attributes
66
+ * @example
67
+ *
68
+ * ```js
69
+ * $('.apple').attr({ id: 'favorite' }).prop('outerHTML');
70
+ * //=> <li class="apple" id="favorite">Apple</li>
71
+ * ```
72
+ *
73
+ * @param values - Map of attribute names and values.
74
+ * @returns The instance itself.
75
+ * @see {@link https://api.jquery.com/attr/}
76
+ */
77
+ export declare function attr<T extends AnyNode>(this: Cheerio<T>, values: Record<string, string | null>): Cheerio<T>;
78
+ interface StyleProp {
79
+ length: number;
80
+ [key: string]: string | number;
81
+ [index: number]: string;
82
+ }
83
+ /**
84
+ * Method for getting and setting properties. Gets the property value for only
85
+ * the first element in the matched set.
86
+ *
87
+ * @category Attributes
88
+ * @example
89
+ *
90
+ * ```js
91
+ * $('input[type="checkbox"]').prop('checked');
92
+ * //=> false
93
+ *
94
+ * $('input[type="checkbox"]').prop('checked', true).val();
95
+ * //=> ok
96
+ * ```
97
+ *
98
+ * @param name - Name of the property.
99
+ * @returns If `value` is specified the instance itself, otherwise the prop's
100
+ * value.
101
+ * @see {@link https://api.jquery.com/prop/}
102
+ */
103
+ export declare function prop<T extends AnyNode>(this: Cheerio<T>, name: 'tagName' | 'nodeName'): string | undefined;
104
+ export declare function prop<T extends AnyNode>(this: Cheerio<T>, name: 'innerHTML' | 'outerHTML' | 'innerText' | 'textContent'): string | null;
105
+ /**
106
+ * Get a parsed CSS style object.
107
+ *
108
+ * @param name - Name of the property.
109
+ * @returns The style object, or `undefined` if the element has no `style`
110
+ * attribute.
111
+ */
112
+ export declare function prop<T extends AnyNode>(this: Cheerio<T>, name: 'style'): StyleProp | undefined;
113
+ /**
114
+ * Resolve `href` or `src` of supported elements. Requires the `baseURI` option
115
+ * to be set, and a global `URL` object to be part of the environment.
116
+ *
117
+ * @example With `baseURI` set to `'https://example.com'`:
118
+ *
119
+ * ```js
120
+ * $('<img src="image.png">').prop('src');
121
+ * //=> 'https://example.com/image.png'
122
+ * ```
123
+ *
124
+ * @param name - Name of the property.
125
+ * @returns The resolved URL, or `undefined` if the element is not supported.
126
+ */
127
+ export declare function prop<T extends AnyNode>(this: Cheerio<T>, name: 'href' | 'src'): string | undefined;
128
+ /**
129
+ * Get a property of an element.
130
+ *
131
+ * @param name - Name of the property.
132
+ * @returns The property's value.
133
+ */
134
+ export declare function prop<T extends AnyNode, K extends keyof Element>(this: Cheerio<T>, name: K): Element[K];
135
+ /**
136
+ * Set a property of an element.
137
+ *
138
+ * @param name - Name of the property.
139
+ * @param value - Value to set the property to.
140
+ * @returns The instance itself.
141
+ */
142
+ export declare function prop<T extends AnyNode, K extends keyof Element>(this: Cheerio<T>, name: K, value: Element[K] | ((this: Element, i: number, prop: K) => Element[keyof Element])): Cheerio<T>;
143
+ /**
144
+ * Set multiple properties of an element.
145
+ *
146
+ * @example
147
+ *
148
+ * ```js
149
+ * $('input[type="checkbox"]').prop({
150
+ * checked: true,
151
+ * disabled: false,
152
+ * });
153
+ * ```
154
+ *
155
+ * @param map - Object of properties to set.
156
+ * @returns The instance itself.
157
+ */
158
+ export declare function prop<T extends AnyNode>(this: Cheerio<T>, map: Record<string, string | Element[keyof Element] | boolean>): Cheerio<T>;
159
+ /**
160
+ * Set a property of an element.
161
+ *
162
+ * @param name - Name of the property.
163
+ * @param value - Value to set the property to.
164
+ * @returns The instance itself.
165
+ */
166
+ export declare function prop<T extends AnyNode>(this: Cheerio<T>, name: string, value: string | boolean | null | ((this: Element, i: number, prop: string) => string | boolean)): Cheerio<T>;
167
+ /**
168
+ * Get a property of an element.
169
+ *
170
+ * @param name - The property's name.
171
+ * @returns The property's value.
172
+ */
173
+ export declare function prop<T extends AnyNode>(this: Cheerio<T>, name: string): string;
174
+ /**
175
+ * Method for getting data attributes, for only the first element in the matched
176
+ * set.
177
+ *
178
+ * @category Attributes
179
+ * @example
180
+ *
181
+ * ```js
182
+ * $('<div data-apple-color="red"></div>').data('apple-color');
183
+ * //=> 'red'
184
+ * ```
185
+ *
186
+ * @param name - Name of the data attribute.
187
+ * @returns The data attribute's value, or `undefined` if the attribute does not
188
+ * exist.
189
+ * @see {@link https://api.jquery.com/data/}
190
+ */
191
+ export declare function data<T extends AnyNode>(this: Cheerio<T>, name: string): unknown;
192
+ /**
193
+ * Method for getting all of an element's data attributes, for only the first
194
+ * element in the matched set.
195
+ *
196
+ * @category Attributes
197
+ * @example
198
+ *
199
+ * ```js
200
+ * $('<div data-apple-color="red"></div>').data();
201
+ * //=> { appleColor: 'red' }
202
+ * ```
203
+ *
204
+ * @returns A map with all of the data attributes.
205
+ * @see {@link https://api.jquery.com/data/}
206
+ */
207
+ export declare function data<T extends AnyNode>(this: Cheerio<T>): Record<string, unknown>;
208
+ /**
209
+ * Method for setting data attributes, for only the first element in the matched
210
+ * set.
211
+ *
212
+ * @category Attributes
213
+ * @example
214
+ *
215
+ * ```js
216
+ * const apple = $('.apple').data('kind', 'mac');
217
+ *
218
+ * apple.data('kind');
219
+ * //=> 'mac'
220
+ * ```
221
+ *
222
+ * @param name - Name of the data attribute.
223
+ * @param value - The new value.
224
+ * @returns The instance itself.
225
+ * @see {@link https://api.jquery.com/data/}
226
+ */
227
+ export declare function data<T extends AnyNode>(this: Cheerio<T>, name: string, value: unknown): Cheerio<T>;
228
+ /**
229
+ * Method for setting multiple data attributes at once, for only the first
230
+ * element in the matched set.
231
+ *
232
+ * @category Attributes
233
+ * @example
234
+ *
235
+ * ```js
236
+ * const apple = $('.apple').data({ kind: 'mac' });
237
+ *
238
+ * apple.data('kind');
239
+ * //=> 'mac'
240
+ * ```
241
+ *
242
+ * @param values - Map of names to values.
243
+ * @returns The instance itself.
244
+ * @see {@link https://api.jquery.com/data/}
245
+ */
246
+ export declare function data<T extends AnyNode>(this: Cheerio<T>, values: Record<string, unknown>): Cheerio<T>;
247
+ /**
248
+ * Method for getting the value of input, select, and textarea. Note: Support
249
+ * for `map`, and `function` has not been added yet.
250
+ *
251
+ * @category Attributes
252
+ * @example
253
+ *
254
+ * ```js
255
+ * $('input[type="text"]').val();
256
+ * //=> input_text
257
+ * ```
258
+ *
259
+ * @returns The value.
260
+ * @see {@link https://api.jquery.com/val/}
261
+ */
262
+ export declare function val<T extends AnyNode>(this: Cheerio<T>): string | undefined | string[];
263
+ /**
264
+ * Method for setting the value of input, select, and textarea. Note: Support
265
+ * for `map`, and `function` has not been added yet.
266
+ *
267
+ * @category Attributes
268
+ * @example
269
+ *
270
+ * ```js
271
+ * $('input[type="text"]').val('test').prop('outerHTML');
272
+ * //=> <input type="text" value="test"/>
273
+ * ```
274
+ *
275
+ * @param value - The new value.
276
+ * @returns The instance itself.
277
+ * @see {@link https://api.jquery.com/val/}
278
+ */
279
+ export declare function val<T extends AnyNode>(this: Cheerio<T>, value: string | string[]): Cheerio<T>;
280
+ /**
281
+ * Method for removing attributes by `name`.
282
+ *
283
+ * @category Attributes
284
+ * @example
285
+ *
286
+ * ```js
287
+ * $('.pear').removeAttr('class').prop('outerHTML');
288
+ * //=> <li>Pear</li>
289
+ *
290
+ * $('.apple').attr('id', 'favorite');
291
+ * $('.apple').removeAttr('id class').prop('outerHTML');
292
+ * //=> <li>Apple</li>
293
+ * ```
294
+ *
295
+ * @param name - Name of the attribute.
296
+ * @returns The instance itself.
297
+ * @see {@link https://api.jquery.com/removeAttr/}
298
+ */
299
+ export declare function removeAttr<T extends AnyNode>(this: Cheerio<T>, name: string): Cheerio<T>;
300
+ /**
301
+ * Check to see if _any_ of the matched elements have the given `className`.
302
+ *
303
+ * @category Attributes
304
+ * @example
305
+ *
306
+ * ```js
307
+ * $('.pear').hasClass('pear');
308
+ * //=> true
309
+ *
310
+ * $('apple').hasClass('fruit');
311
+ * //=> false
312
+ *
313
+ * $('li').hasClass('pear');
314
+ * //=> true
315
+ * ```
316
+ *
317
+ * @param className - Name of the class.
318
+ * @returns Indicates if an element has the given `className`.
319
+ * @see {@link https://api.jquery.com/hasClass/}
320
+ */
321
+ export declare function hasClass<T extends AnyNode>(this: Cheerio<T>, className: string): boolean;
322
+ /**
323
+ * Adds class(es) to all of the matched elements. Also accepts a `function`.
324
+ *
325
+ * @category Attributes
326
+ * @example
327
+ *
328
+ * ```js
329
+ * $('.pear').addClass('fruit').prop('outerHTML');
330
+ * //=> <li class="pear fruit">Pear</li>
331
+ *
332
+ * $('.apple').addClass('fruit red').prop('outerHTML');
333
+ * //=> <li class="apple fruit red">Apple</li>
334
+ * ```
335
+ *
336
+ * @param value - Name of new class.
337
+ * @returns The instance itself.
338
+ * @see {@link https://api.jquery.com/addClass/}
339
+ */
340
+ export declare function addClass<T extends AnyNode, R extends ArrayLike<T>>(this: R, value?: string | ((this: Element, i: number, className: string) => string | undefined)): R;
341
+ /**
342
+ * Removes one or more space-separated classes from the selected elements. If no
343
+ * `className` is defined, all classes will be removed. Also accepts a
344
+ * `function`.
345
+ *
346
+ * @category Attributes
347
+ * @example
348
+ *
349
+ * ```js
350
+ * $('.pear').removeClass('pear').prop('outerHTML');
351
+ * //=> <li class="">Pear</li>
352
+ *
353
+ * $('.apple').addClass('red').removeClass().prop('outerHTML');
354
+ * //=> <li class="">Apple</li>
355
+ * ```
356
+ *
357
+ * @param name - Name of the class. If not specified, removes all elements.
358
+ * @returns The instance itself.
359
+ * @see {@link https://api.jquery.com/removeClass/}
360
+ */
361
+ export declare function removeClass<T extends AnyNode, R extends ArrayLike<T>>(this: R, name?: string | ((this: Element, i: number, className: string) => string | undefined)): R;
362
+ /**
363
+ * Add or remove class(es) from the matched elements, depending on either the
364
+ * class's presence or the value of the switch argument. Also accepts a
365
+ * `function`.
366
+ *
367
+ * @category Attributes
368
+ * @example
369
+ *
370
+ * ```js
371
+ * $('.apple.green').toggleClass('fruit green red').prop('outerHTML');
372
+ * //=> <li class="apple fruit red">Apple</li>
373
+ *
374
+ * $('.apple.green').toggleClass('fruit green red', true).prop('outerHTML');
375
+ * //=> <li class="apple green fruit red">Apple</li>
376
+ * ```
377
+ *
378
+ * @param value - Name of the class. Can also be a function.
379
+ * @param stateVal - If specified the state of the class.
380
+ * @returns The instance itself.
381
+ * @see {@link https://api.jquery.com/toggleClass/}
382
+ */
383
+ export declare function toggleClass<T extends AnyNode, R extends ArrayLike<T>>(this: R, value?: string | ((this: Element, i: number, className: string, stateVal?: boolean) => string), stateVal?: boolean): R;
384
+ export {};
385
+ //# sourceMappingURL=attributes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../../src/api/attributes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,EAAS,KAAK,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AA6F7C;;;;;;;;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