@@ -13,7 +13,7 @@ import path from 'node:path'
13
13
import assert from 'node:assert'
14
14
import test from 'tape'
15
15
import { isHidden } from 'is-hidden'
16
- import parse5 from 'parse5'
16
+ import { parse , parseFragment } from 'parse5'
17
17
import { visit } from 'unist-util-visit'
18
18
import { toVFile } from 'to-vfile'
19
19
import { fromParse5 } from '../index.js'
@@ -24,7 +24,7 @@ test('hast-util-from-parse5', (t) => {
24
24
const file = toVFile ( { value : '<title>Hello!</title><h1>World!' } )
25
25
26
26
t . deepEqual (
27
- fromParse5 ( parse5 . parse ( String ( file ) ) ) ,
27
+ fromParse5 ( parse ( String ( file ) ) ) ,
28
28
{
29
29
type : 'root' ,
30
30
children : [
@@ -68,7 +68,7 @@ test('hast-util-from-parse5', (t) => {
68
68
)
69
69
70
70
t . deepEqual (
71
- fromParse5 ( parse5 . parseFragment ( String ( file ) ) ) ,
71
+ fromParse5 ( parseFragment ( String ( file ) ) ) ,
72
72
{
73
73
type : 'root' ,
74
74
children : [
@@ -91,10 +91,7 @@ test('hast-util-from-parse5', (t) => {
91
91
)
92
92
93
93
t . deepEqual (
94
- fromParse5 (
95
- parse5 . parse ( String ( file ) , { sourceCodeLocationInfo : true } ) ,
96
- file
97
- ) ,
94
+ fromParse5 ( parse ( String ( file ) , { sourceCodeLocationInfo : true } ) , file ) ,
98
95
{
99
96
type : 'root' ,
100
97
children : [
@@ -168,7 +165,7 @@ test('hast-util-from-parse5', (t) => {
168
165
)
169
166
170
167
t . deepEqual (
171
- fromParse5 ( parse5 . parse ( String ( file ) ) , file ) ,
168
+ fromParse5 ( parse ( String ( file ) ) , file ) ,
172
169
{
173
170
type : 'root' ,
174
171
children : [
@@ -227,16 +224,17 @@ test('hast-util-from-parse5', (t) => {
227
224
nodeName : 'title' ,
228
225
tagName : 'title' ,
229
226
attrs : [ ] ,
227
+ // @ts -expect-error: fine.
230
228
namespaceURI : 'http://www.w3.org/1999/xhtml' ,
231
229
childNodes : [
232
230
{
233
231
nodeName : '#text' ,
234
232
value : 'Hello!' ,
235
- // @ts -expect-error runtime .
233
+ // @ts -expect-error: fine .
236
234
sourceCodeLocation : { }
237
235
}
238
236
] ,
239
- // @ts -expect-error runtime .
237
+ // @ts -expect-error: fine .
240
238
sourceCodeLocation : {
241
239
startLine : 1 ,
242
240
startCol : 1 ,
@@ -266,11 +264,12 @@ test('hast-util-from-parse5', (t) => {
266
264
nodeName : 'p' ,
267
265
tagName : 'p' ,
268
266
attrs : [ ] ,
267
+ // @ts -expect-error: fine.
269
268
namespaceURI : 'http://www.w3.org/1999/xhtml' ,
270
269
childNodes : [
271
- // @ts -expect-error runtime.
272
270
{
273
271
nodeName : '#text' ,
272
+ // @ts -expect-error: fine.
274
273
value : 'Hello!' ,
275
274
sourceCodeLocation : {
276
275
startLine : 1 ,
@@ -282,7 +281,7 @@ test('hast-util-from-parse5', (t) => {
282
281
}
283
282
}
284
283
] ,
285
- // @ts -expect-error runtime .
284
+ // @ts -expect-error: fine .
286
285
sourceCodeLocation : {
287
286
startLine : 1 ,
288
287
startCol : 1 ,
@@ -315,7 +314,7 @@ test('hast-util-from-parse5', (t) => {
315
314
316
315
t . deepEqual (
317
316
fromParse5 (
318
- parse5 . parseFragment (
317
+ parseFragment (
319
318
[
320
319
'<svg width="230" height="120" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">' ,
321
320
'<circle cx="60" cy="60" r="50" fill="red"/>' ,
@@ -394,7 +393,7 @@ test('fixtures', (t) => {
394
393
* @param {Options } options
395
394
*/
396
395
function checkYesYes ( t , options ) {
397
- const input = parse5 . parse ( String ( options . file ) , {
396
+ const input = parse ( String ( options . file ) , {
398
397
sourceCodeLocationInfo : true
399
398
} )
400
399
const actual = fromParse5 ( input , { file : options . file , verbose : true } )
@@ -418,7 +417,7 @@ test('fixtures', (t) => {
418
417
* @param {Options } options
419
418
*/
420
419
function checkNoYes ( t , options ) {
421
- const input = parse5 . parse ( String ( options . file ) )
420
+ const input = parse ( String ( options . file ) )
422
421
const actual = fromParse5 ( input , { file : options . file , verbose : true } )
423
422
/** @type {Node } */
424
423
const expected = JSON . parse ( String ( fs . readFileSync ( options . out ) ) )
@@ -434,7 +433,7 @@ test('fixtures', (t) => {
434
433
* @param {Options } options
435
434
*/
436
435
function checkYesNo ( t , options ) {
437
- const input = parse5 . parse ( String ( options . file ) , {
436
+ const input = parse ( String ( options . file ) , {
438
437
sourceCodeLocationInfo : true
439
438
} )
440
439
const actual = fromParse5 ( input )
@@ -452,7 +451,7 @@ test('fixtures', (t) => {
452
451
* @param {Options } options
453
452
*/
454
453
function checkNoNo ( t , options ) {
455
- const input = parse5 . parse ( String ( options . file ) )
454
+ const input = parse ( String ( options . file ) )
456
455
const actual = fromParse5 ( input )
457
456
/** @type {Node } */
458
457
const expected = JSON . parse ( String ( fs . readFileSync ( options . out ) ) )
0 commit comments