How to use the jsdom.JSDOM.fragment function in jsdom

To help you get started, we’ve selected a few jsdom examples, based on popular ways it is used in public projects.

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

github launchlet / launchlet / os-app / dev-launcher / recipes / subjects / LCHActiveDocumentFocusElements / main-tests.js View on Github external
it('includes if name', function() {
			deepEqual(mainModule.LCHActiveDocumentsFocusElements(JSDOM.fragment('<input name="alfa">')).length, 1);
		});
github launchlet / launchlet / os-app / dev-launcher / recipes / subjects / LCHActiveDocumentFocusElements / main-tests.js View on Github external
it('sets to DOMElement', function() {
				deepEqual(mainModule.LCHActiveDocumentsFocusElements(JSDOM.fragment('<a title="#" href="#">alfa</a>')).pop().LCHRecipeOutputType, 'DOMElement');
			});
github launchlet / launchlet / os-app / dev-launcher / recipes / subjects / LCHActiveDocumentFocusElements / main-tests.js View on Github external
it('excludes if tabindex -1', function() {
			deepEqual(mainModule.LCHActiveDocumentsFocusElements(JSDOM.fragment('<button tabindex="-1">alfa</button>')), []);
		});
github launchlet / launchlet / os-app / dev-launcher / recipes / subjects / LCHActiveDocumentFocusElements / main-tests.js View on Github external
it('excludes if disabled', function() {
			deepEqual(mainModule.LCHActiveDocumentsFocusElements(JSDOM.fragment('<button disabled="">alfa</button>')), []);
		});
github launchlet / launchlet / os-app / dev-launcher / recipes / subjects / LCHActiveDocumentFocusElements / main-tests.js View on Github external
it('excludes if title only whitespace', function() {
			deepEqual(mainModule.LCHActiveDocumentsFocusElements(JSDOM.fragment('<a title="" href="#"></a>')), []);
		});
github PonyCui / SVGAPlayer-SVG / src / generator.ts View on Github external
constructor(readonly videoItem: VideoEntity, readonly loops: number = 0) {
        this.svgElement = JSDOM.fragment(`<svg viewBox="0 0 ${videoItem.videoSize.width} ${videoItem.videoSize.height}" style="background-color: black" xmlns="http://www.w3.org/2000/svg" version="1.1"></svg>`)
        this.dom.window.document.body.appendChild(this.svgElement)
    }
github microsoft / TSJS-lib-generator / src / idlfetcher.ts View on Github external
async function fetchIDL(source: IDLSource) {
    const response = await fetch(source.url);
    if (source.url.endsWith(".idl")) {
        return { idl: await response.text() };
    }
    const dom = JSDOM.fragment(await response.text());
    let idl = extractIDL(dom);
    const css = extractCSSDefinitions(dom);
    if (css) {
        idl = idl ? idl + `\n\n${css}` : css;
    }
    if (!idl) {
        throw new Error(`Found no IDL or CSS from ${source.url}`);
    }
    const comments = processComments(dom);
    return { idl, comments };
}
github adobe / helix-pipeline / src / utils / mdast-to-vdom.js View on Github external
static sanitizeInlineHTML(node) {
    const stack = [];
    for (let i = 0; i &lt; node.children.length; i += 1) {
      const child = node.children[i];
      if (child.type === 'raw') {
        if (child.value.firstElementChild === null) {
          if (stack.length === 0) {
            throw new Error(`no matching inline element found for ${child.html}`);
          } else {
            const last = stack.pop();
            let html = '';
            for (let j = last; j &lt;= i; j += 1) {
              html += node.children[j].html || node.children[j].value;
            }
            node.children[last].value = JSDOM.fragment(html);
            node.children[last].html = html;
            node.children.splice(last + 1, i - last);
            i = last;
          }
        } else {
          stack.push(i);
        }
      } else if (child.children &amp;&amp; child.children.length) {
        VDOMTransformer.sanitizeInlineHTML(child);
      }
    }
  }
github onerzafer / microfe / src / modules / StitchingLayer / stitching-layer.service.ts View on Github external
fs.readFile(join(__dirname, '../../templates/client-scripts.template.js'), 'utf8', (err, data) =&gt; {
                if (err) {
                    reject(err);
                } else {
                    const clientScripts = JSDOM.fragment(`
                        
                        
                        
                        
                    `);
                    parsedFragments.window.document.getElementsByTagName('head')[0].appendChild(clientScripts);
                    resolve(parsedFragments);
                }
            });
        });
github springload / metatemplate / src / template-formats / html / template.html.ts View on Github external
const getAttr = (attr: string, name: string): string => {
  if (!attr.includes(name)) return undefined;
  const frag = JSDOM.fragment(attr);
  let value;
  const firstChild = frag.firstChild;
  if (firstChild.nodeType === 1) {
    value = (firstChild as Element).getAttribute(name);
    value = value.replace(/\!/, "");
  }
  return value;
};