Skip to content

Commit 4389c8f

Browse files
committed
Replace dependency
1 parent 0c022bd commit 4389c8f

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

lib/index.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
* replacement node that we’ll swap back in afterwards.
5050
*/
5151

52-
import extend from 'extend'
52+
import structuredClone from '@ungap/structured-clone'
5353
import {fromParse5} from 'hast-util-from-parse5'
5454
import {toParse5} from 'hast-util-to-parse5'
5555
import {htmlVoidElements} from 'html-void-elements'
@@ -422,8 +422,6 @@ function resetTokenizer(state, point) {
422422
setPoint(state, point)
423423

424424
// Process final characters if they’re still there after hibernating.
425-
// Similar to:
426-
// See: <https://github.com/inikulin/parse5/blob/9c683e1/packages/parse5/lib/extensions/location-info/tokenizer-mixin.js#L95>.
427425
/** @type {CharacterToken} */
428426
// @ts-expect-error: private.
429427
// type-coverage:ignore-next-line
@@ -442,7 +440,7 @@ function resetTokenizer(state, point) {
442440
}
443441

444442
// Reset tokenizer:
445-
// See: <https://github.com/inikulin/parse5/blob/edb85df/packages/parse5/lib/tokenizer/index.ts#L225-L249>.
443+
// See: <https://github.com/inikulin/parse5/blob/6f7ca60/packages/parse5/lib/tokenizer/index.ts#L187-L223>.
446444
// Especially putting it back in the `data` state is useful: some elements,
447445
// like textareas and iframes, change the state.
448446
// See GH-7.
@@ -707,6 +705,6 @@ function createParse5Location(node) {
707705
*/
708706
function cloneWithoutChildren(node) {
709707
return 'children' in node
710-
? extend(true, {}, {...node, children: []})
711-
: extend(true, {}, node)
708+
? structuredClone({...node, children: []})
709+
: structuredClone(node)
712710
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
],
3636
"dependencies": {
3737
"@types/hast": "^3.0.0",
38-
"extend": "^3.0.0",
38+
"@ungap/structured-clone": "^1.0.0",
3939
"hast-util-from-parse5": "^8.0.0",
4040
"hast-util-to-parse5": "^8.0.0",
4141
"html-void-elements": "^3.0.0",
@@ -49,6 +49,7 @@
4949
},
5050
"devDependencies": {
5151
"@types/node": "^20.0.0",
52+
"@types/ungap__structured-clone": "^0.3.0",
5253
"c8": "^8.0.0",
5354
"hast-util-to-html": "^8.0.0",
5455
"hastscript": "^8.0.0",

0 commit comments

Comments
 (0)