Browse Source

Setup DomParser

pull/3691/head
Artur Arseniev 5 years ago
parent
commit
8623113187
  1. 4
      src/parser/config/config.js
  2. 2
      src/parser/model/BrowserParserHtml.js

4
src/parser/config/config.js

@ -4,9 +4,9 @@ export default {
// Custom CSS parser
parserCss: null,
// Default DOMParser mime type
// DOMParser mime type (default 'text/html')
// @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser/parseFromString
htmlType: 'text/html',
htmlType: null,
// Custom function which tells which root Element to extract
// from the DOMParser.parseFromString result

2
src/parser/model/BrowserParserHtml.js

@ -1,7 +1,7 @@
export default (str, config = {}) => {
const { htmlResult } = config;
const parser = new DOMParser();
const doc = parser.parseFromString(str, config.htmlType);
const doc = parser.parseFromString(str, config.htmlType || 'text/html');
return htmlResult ? htmlResult(doc, str) : doc.body;
};

Loading…
Cancel
Save