MfmService.toHtml を JSDOM に戻す (MisskeyIO#647)

This commit is contained in:
riku6460 2024-06-14 06:36:37 +09:00 committed by GitHub
parent 57a785ca2a
commit 64c0f62339
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -6,7 +6,7 @@
import { URL } from 'node:url'; import { URL } from 'node:url';
import { Inject, Injectable } from '@nestjs/common'; import { Inject, Injectable } from '@nestjs/common';
import * as parse5 from 'parse5'; import * as parse5 from 'parse5';
import { Window, XMLSerializer } from 'happy-dom'; import { JSDOM } from 'jsdom';
import { DI } from '@/di-symbols.js'; import { DI } from '@/di-symbols.js';
import type { Config } from '@/config.js'; import type { Config } from '@/config.js';
import { intersperse } from '@/misc/prelude/array.js'; import { intersperse } from '@/misc/prelude/array.js';
@ -243,9 +243,9 @@ export class MfmService {
return null; return null;
} }
const { window } = new Window(); const fragment = JSDOM.fragment('');
const doc = window.document; const doc = fragment.ownerDocument;
const body = doc.createElement('p'); const body = doc.createElement('p');
@ -461,6 +461,6 @@ export class MfmService {
appendChildren(nodes, body); appendChildren(nodes, body);
return new XMLSerializer().serializeToString(body); return body.outerHTML;
} }
} }