10 examples of 'domparser nodejs' in JavaScript

Every line of 'domparser nodejs' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
436function domGetSource() {
437 return eTextarea.value;
438},
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

17function getSharedDOMParserWithValue (html, name = 'default') {
18 let dom = getSharedDOMParser(name);
19 dom.innerHTML = html;
20 return dom;
21}
56function parseHTMLToDOM (html_str) {
57 /* Parses a string with HTML and returns a DOM element.
58 *
59 * Forked from vdom_parser:
60 * https://github.com/bitinn/vdom-parser
61 */
62 if (typeof html_str !== 'string') {
63 throw new Error('Invalid parameter type in parseHTMLToDOM');
64 }
65 if ( !('DOMParser' in window) ) {
66 throw new Error(
67 'DOMParser is not available, '+
68 'so parsing string to DOM node is not possible.');
69 }
70 if (!html_str) {
71 return document.createTextNode('');
72 }
73 domParser = domParser || new DOMParser();
74 const doc = domParser.parseFromString(html_str, 'text/html');
75
76 // most tags default to body
77 if (doc.body.firstChild) {
78 return doc.getElementsByTagName('body')[0].firstChild;
79
80 // some tags, like script and style, default to head
81 } else if (doc.head.firstChild && (doc.head.firstChild.tagName !== 'TITLE' || doc.title)) {
82 return doc.head.firstChild;
83
84 // special case for html comment, cdata, doctype
85 } else if (doc.firstChild && doc.firstChild.tagName !== 'HTML') {
86 return doc.firstChild;
87
88 // other element, such as whitespace, or html/body/head tag, fallback to empty text node
89 } else {
90 return document.createTextNode('');
91 }
92}
3function jsdom () {
4 try {
5 return require('jsdom').jsdom;
6 } catch (e) {
7 throw new Error('domador requires you to install optional dependency `jsdom` to enable its server-side functionality.');
8 }
9}
148createParser() {
149 return new jtree.TreeNode.Parser(memberNode, undefined, undefined)
150}
537createParser() {
538 return new jtree.TreeNode.Parser(catchAllMultilineStringConstantNode, undefined, undefined)
539}
28isTextNode(node) {
29 return node.nodeType === Node.TEXT_NODE;
30}
7function parser(doc, file) {
8 const create = settings.fragment == null || settings.fragment ? createFragment : createDocument;
9 return fromDOM(create(String(file)));
10}
287fromNative(node) {
288 return new El(node);
289}
903createParser() {
904 return new jtree.TreeNode.Parser(lineOfHtmlContentNode, undefined, undefined)
905}

Related snippets