@@ -13,7 +13,7 @@ import path from 'node:path'
1313import assert from 'node:assert'
1414import test from 'tape'
1515import { isHidden } from 'is-hidden'
16- import parse5 from 'parse5'
16+ import { parse , parseFragment } from 'parse5'
1717import { visit } from 'unist-util-visit'
1818import { toVFile } from 'to-vfile'
1919import { fromParse5 } from '../index.js'
@@ -24,7 +24,7 @@ test('hast-util-from-parse5', (t) => {
2424 const file = toVFile ( { value : '<title>Hello!</title><h1>World!' } )
2525
2626 t . deepEqual (
27- fromParse5 ( parse5 . parse ( String ( file ) ) ) ,
27+ fromParse5 ( parse ( String ( file ) ) ) ,
2828 {
2929 type : 'root' ,
3030 children : [
@@ -68,7 +68,7 @@ test('hast-util-from-parse5', (t) => {
6868 )
6969
7070 t . deepEqual (
71- fromParse5 ( parse5 . parseFragment ( String ( file ) ) ) ,
71+ fromParse5 ( parseFragment ( String ( file ) ) ) ,
7272 {
7373 type : 'root' ,
7474 children : [
@@ -91,10 +91,7 @@ test('hast-util-from-parse5', (t) => {
9191 )
9292
9393 t . deepEqual (
94- fromParse5 (
95- parse5 . parse ( String ( file ) , { sourceCodeLocationInfo : true } ) ,
96- file
97- ) ,
94+ fromParse5 ( parse ( String ( file ) , { sourceCodeLocationInfo : true } ) , file ) ,
9895 {
9996 type : 'root' ,
10097 children : [
@@ -168,7 +165,7 @@ test('hast-util-from-parse5', (t) => {
168165 )
169166
170167 t . deepEqual (
171- fromParse5 ( parse5 . parse ( String ( file ) ) , file ) ,
168+ fromParse5 ( parse ( String ( file ) ) , file ) ,
172169 {
173170 type : 'root' ,
174171 children : [
@@ -227,16 +224,17 @@ test('hast-util-from-parse5', (t) => {
227224 nodeName : 'title' ,
228225 tagName : 'title' ,
229226 attrs : [ ] ,
227+ // @ts -expect-error: fine.
230228 namespaceURI : 'http://www.w3.org/1999/xhtml' ,
231229 childNodes : [
232230 {
233231 nodeName : '#text' ,
234232 value : 'Hello!' ,
235- // @ts -expect-error runtime .
233+ // @ts -expect-error: fine .
236234 sourceCodeLocation : { }
237235 }
238236 ] ,
239- // @ts -expect-error runtime .
237+ // @ts -expect-error: fine .
240238 sourceCodeLocation : {
241239 startLine : 1 ,
242240 startCol : 1 ,
@@ -266,11 +264,12 @@ test('hast-util-from-parse5', (t) => {
266264 nodeName : 'p' ,
267265 tagName : 'p' ,
268266 attrs : [ ] ,
267+ // @ts -expect-error: fine.
269268 namespaceURI : 'http://www.w3.org/1999/xhtml' ,
270269 childNodes : [
271- // @ts -expect-error runtime.
272270 {
273271 nodeName : '#text' ,
272+ // @ts -expect-error: fine.
274273 value : 'Hello!' ,
275274 sourceCodeLocation : {
276275 startLine : 1 ,
@@ -282,7 +281,7 @@ test('hast-util-from-parse5', (t) => {
282281 }
283282 }
284283 ] ,
285- // @ts -expect-error runtime .
284+ // @ts -expect-error: fine .
286285 sourceCodeLocation : {
287286 startLine : 1 ,
288287 startCol : 1 ,
@@ -315,7 +314,7 @@ test('hast-util-from-parse5', (t) => {
315314
316315 t . deepEqual (
317316 fromParse5 (
318- parse5 . parseFragment (
317+ parseFragment (
319318 [
320319 '<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">' ,
321320 '<circle cx="60" cy="60" r="50" fill="red"/>' ,
@@ -394,7 +393,7 @@ test('fixtures', (t) => {
394393 * @param {Options } options
395394 */
396395 function checkYesYes ( t , options ) {
397- const input = parse5 . parse ( String ( options . file ) , {
396+ const input = parse ( String ( options . file ) , {
398397 sourceCodeLocationInfo : true
399398 } )
400399 const actual = fromParse5 ( input , { file : options . file , verbose : true } )
@@ -418,7 +417,7 @@ test('fixtures', (t) => {
418417 * @param {Options } options
419418 */
420419 function checkNoYes ( t , options ) {
421- const input = parse5 . parse ( String ( options . file ) )
420+ const input = parse ( String ( options . file ) )
422421 const actual = fromParse5 ( input , { file : options . file , verbose : true } )
423422 /** @type {Node } */
424423 const expected = JSON . parse ( String ( fs . readFileSync ( options . out ) ) )
@@ -434,7 +433,7 @@ test('fixtures', (t) => {
434433 * @param {Options } options
435434 */
436435 function checkYesNo ( t , options ) {
437- const input = parse5 . parse ( String ( options . file ) , {
436+ const input = parse ( String ( options . file ) , {
438437 sourceCodeLocationInfo : true
439438 } )
440439 const actual = fromParse5 ( input )
@@ -452,7 +451,7 @@ test('fixtures', (t) => {
452451 * @param {Options } options
453452 */
454453 function checkNoNo ( t , options ) {
455- const input = parse5 . parse ( String ( options . file ) )
454+ const input = parse ( String ( options . file ) )
456455 const actual = fromParse5 ( input )
457456 /** @type {Node } */
458457 const expected = JSON . parse ( String ( fs . readFileSync ( options . out ) ) )
0 commit comments