Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('includes if name', function() {
deepEqual(mainModule.LCHActiveDocumentsFocusElements(JSDOM.fragment('<input name="alfa">')).length, 1);
});
it('sets to DOMElement', function() {
deepEqual(mainModule.LCHActiveDocumentsFocusElements(JSDOM.fragment('<a title="#" href="#">alfa</a>')).pop().LCHRecipeOutputType, 'DOMElement');
});
it('excludes if tabindex -1', function() {
deepEqual(mainModule.LCHActiveDocumentsFocusElements(JSDOM.fragment('<button tabindex="-1">alfa</button>')), []);
});
it('excludes if disabled', function() {
deepEqual(mainModule.LCHActiveDocumentsFocusElements(JSDOM.fragment('<button disabled="">alfa</button>')), []);
});
it('excludes if title only whitespace', function() {
deepEqual(mainModule.LCHActiveDocumentsFocusElements(JSDOM.fragment('<a title="" href="#"></a>')), []);
});
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)
}
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 };
}
static sanitizeInlineHTML(node) {
const stack = [];
for (let i = 0; i < 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 <= 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 && child.children.length) {
VDOMTransformer.sanitizeInlineHTML(child);
}
}
}
fs.readFile(join(__dirname, '../../templates/client-scripts.template.js'), 'utf8', (err, data) => {
if (err) {
reject(err);
} else {
const clientScripts = JSDOM.fragment(`
`);
parsedFragments.window.document.getElementsByTagName('head')[0].appendChild(clientScripts);
resolve(parsedFragments);
}
});
});
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;
};