mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-06-07 09:25:29 +08:00
Update packages/html/src/createSafeParser.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
08b158d10e
commit
70ff7a1721
@ -2,6 +2,14 @@ import type { DOMParser as HappyDOMParser, Window as HappyDOMWindow } from 'happ
|
||||
|
||||
import { preserveAndRestoreNodeInternals } from './preserveAndRestoreNodeInternals.js'
|
||||
|
||||
/**
|
||||
* Creates a safe DOMParser instance by wrapping `happy-dom`'s `DOMParser`.
|
||||
* This function ensures that the original `process` is preserved by using
|
||||
* `preserveAndRestoreNodeInternals`.
|
||||
*
|
||||
* @param {HappyDOMWindow} window - The `happy-dom` window object to use for the parser.
|
||||
* @returns {HappyDOMParser} A new instance of `happy-dom`'s `DOMParser`.
|
||||
*/
|
||||
export function createSafeParser(window: HappyDOMWindow) {
|
||||
return preserveAndRestoreNodeInternals(() => {
|
||||
const { DOMParser } = require('happy-dom-without-node')
|
||||
|
Loading…
Reference in New Issue
Block a user