Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (!element.attribs.layout) {
setLayoutAttribute(element);
}
}
}
// convert all of the img elements first so that we can perform lengthy
// network requests in parallel before sequentially traversing the DOM
if (self.config['amp-img']) {
var imgTest = function(elem) {
return elem.name === 'img' && elem.attribs.src;
}
var imgElems = domutils.findAll(elem => imgTest(elem), data);
var imgTasks = imgElems.map(elem => amperizeImageElem(elem));
await async.parallelLimit(imgTasks, 10);
}
// sequentially traverse the DOM
async.reduce(data, html, function reduce(html, element, step) {
var children;
if (/(style|script|textarea|link)/.test(element.name)) {
return step(null, html);
}
function close(error, html) {
html += helpers.close(element);
step(null, html);
}
public appendChild(html) {
if (typeof html._dom !== "undefined") {
// Document
if (Array.isArray(this._dom)) {
appendChild(this._dom[1], html._dom)
} else {
appendChild(this._dom, html._dom)
}
return html
}
html = new Element(parseDOMSync(html)[0])
return this.appendChild(html)
}
}
public appendChild(html) {
if (typeof html._dom !== "undefined") {
// Document
if (Array.isArray(this._dom)) {
appendChild(this._dom[1], html._dom)
} else {
appendChild(this._dom, html._dom)
}
return html
}
html = new Element(parseDOMSync(html)[0])
return this.appendChild(html)
}
}
return source.alter( function( value ) {
try {
de&&ug( value.dom );
value.content = serialize( value.dom );
} catch( e ) {
value.error = e;
value.content = null;
}
} );
} ); // html_serialize()
module.exports = function (dom, config) {
config = config || {};
// resolve the base url of the document
var base = config.base || '';
var baseElem = DOM.findOne(function (elem) {
return elem.name === 'base' && DOM.hasAttrib(elem, 'href');
}, dom);
if (baseElem) {
base = urlUtil.resolve(base, baseElem.attribs.href);
}
var strict = config.strict;
var idMap = mapIds(dom);
function _getItems (nodes, isTopLevel) {
var items = [];
nodes.forEach(function (node) {
var childIsTopLEvel = isTopLevel;
var isStrictItem = isItem(node) && !isProperty(node);
var isNonStrictItem = isItem(node) && isTopLevel;
dom.forEach(function(child) {
DomUtils.appendChild(elem, child);
});
return this;
helper.getDOM(str).forEach(function(child) {
DomUtils.prepend(elem, child);
});
});
const handler = new DomHandler((error, dom) => {
if (error) {
throw error
} else {
const { attribs } = dom[0]
const { viewbox } = attribs
const [width, height] = viewbox.split(/ +/g).slice(2)
assign(attribs, { width, height })
html = `
${getInnerHTML(dom[0])}
`.trim()
}
})
const parser = new Parser(handler)
function getOneElement(what, where) {
return DomUtils.getElementsByTagName(what, where, true, 1)[0];
}
function fetch(what, where, recurse) {
function bodyElement(dom) {
return DOMUtils.getElementsByTagName('body', dom, true, 2)[0];
}