Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"parser": "babel-eslint",
"extends": "eslint:recommended",
"env": {
"node": true,
"browser": true
},
"rules": {
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,8 @@
"sinon": "^7.3.2",
"sinon-chai": "^3.3.0",
"webpack": "^4.35.3"
},
"dependencies": {
"jsdom": "^16.2.2"
}
}
5 changes: 5 additions & 0 deletions src/parse-markup.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ export default function parseMarkup(markup, type) {

/** A shared frame is used for the fallback HTML parser, built on-demand. */
function buildParserFrame() {
// For node environments, such as for SSR, polyfill document with JSDOM
if (!document) {
const { JSDOM } = require("jsdom");
global.document = new JSDOM().window.document;
}
if (document.implementation && document.implementation.createHTMLDocument) {
return document.implementation.createHTMLDocument('');
}
Expand Down
Loading