From 6e0c055fafca940f13893123fe2303394d48f498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Acid=20Chicken=20=28=E7=A1=AB=E9=85=B8=E9=B6=8F=29?= Date: Sun, 3 Feb 2019 23:49:00 +0900 Subject: [PATCH] Module 'jsdom' as import syntax (#4016) --- package.json | 1 + src/mfm/toHtml.ts | 7 +++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 8eb1cf9657..b480519f99 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "@types/is-root": "1.0.0", "@types/is-svg": "3.0.0", "@types/js-yaml": "3.12.0", + "@types/jsdom": "12.2.1", "@types/katex": "0.5.0", "@types/koa": "2.0.48", "@types/koa-bodyparser": "5.0.2", diff --git a/src/mfm/toHtml.ts b/src/mfm/toHtml.ts index 85e8c8a7fe..e67ccc5035 100644 --- a/src/mfm/toHtml.ts +++ b/src/mfm/toHtml.ts @@ -1,5 +1,4 @@ -const jsdom = require('jsdom'); -const { JSDOM } = jsdom; +import { JSDOM } from 'jsdom'; import config from '../config'; import { INote } from '../models/note'; import { intersperse } from '../prelude/array'; @@ -158,9 +157,9 @@ export function toHtml(tokens: MfmForest, mentionedRemoteUsers: INote['mentioned text(token) { const el = doc.createElement('span'); - const nodes = (token.node.props.text as string).split(/\r\n|\r|\n/).map(x => doc.createTextNode(x)); + const nodes = (token.node.props.text as string).split(/\r\n|\r|\n/).map(x => doc.createTextNode(x) as Node); - for (const x of intersperse('br', nodes)) { + for (const x of intersperse('br', nodes)) { el.appendChild(x === 'br' ? doc.createElement('br') : x); }