Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const adapter = function (e) {
// Validate input
if (typeof e !== 'object') return;
if (typeof e.xml !== 'object') return;
return domToBlocks(html.parseDOM(e.xml.outerHTML));
};
describe('node methods (read ops)', function () {
var p = htmlparser2.parseDOM(
'<p><span></span>'
+ '<a disabled="" data-role="test" href="#" class="y z" id="x">'
+ '<img class="cls" id="c1">'
+ '<span class="cls" id="c2"></span>'
+ '</a>'
+ '<i></i></p>'
)[0];
var p2 = htmlparser2.parseDOM('<p></p>')[0];
transformRecursively(p);
transformRecursively(p2);
it('should have node methods', function () {
var node = p.childNodes[1];
expect(node.hasChildNodes()).toBe(true);
expect(node.firstChild.hasChildNodes()).toBe(false);
expect(node.isEqualNode(node)).toBe(true);
expect(node.isEqualNode(p)).toBe(false);
expect(node.isEqualNode(node.firstChild)).toBe(false);
expect(node.compareDocumentPosition(node)).toBe(0);
test(name, function () {
var src = fs.readFileSync(inputDir + '/' + name + '.jade', 'utf8');
var expected = htmlparser.parseDOM(fs.readFileSync(inputDir + '/' + name + '.html', 'utf8'));
fs.writeFileSync(outputDir + '/' + name + '.jade', src);
var js = jade.compileFileClient(inputDir + '/' + name + '.jade', {
outputFile: outputDir + '/' + name + '.js',
basedir: inputDir
});
fs.writeFileSync(outputDir + '/' + name + '.js', js);
mockDom.mock();
var fn = jade.compileFile(inputDir + '/' + name + '.jade', {
outputFile: outputDir + '/' + name + '.js',
basedir: inputDir
});
var actual = fn({title: 'Jade'});
var hasDiv = expected.filter(function(element) { return element.type !== 'text' }).length !== 1;
actual = hasDiv ? actual.children : actual;
mockDom.reset();
function getDOMFromPath(path, options) {
return htmlparser2.parseDOM(fs.readFileSync(path).toString(), options);
}
const extract = function () {
this.ast = htmlparser.parseDOM(fs.readFileSync(this.name).toString());
domutils.findAll(shouldModify, this.ast).forEach(parseElem, this);
return this;
};
module.exports.find = function find (content, test) {
let dom = parseDOM(content, {
recognizeSelfClosing: true,
lowerCaseAttributeNames: false
})
DomUtils.find(test, dom, true)
return dom
}