Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)
}
}
dom.forEach(function(child) {
DomUtils.appendChild(elem, child);
});
return this;
function rulesToStyleElement(rules) {
const css = stringifyRules(rules);
const textNode = {
type: ElementType.Text,
data: css
};
const styleElement = {
type: ElementType.Style,
name: 'style',
attribs: {},
children: []
};
DOMUtils.appendChild(styleElement, textNode);
return styleElement;
}
data: css
});
const head = DOMUtils.getElementsByTagName('head', dom, true, 2)[0];
if (head)
if (head.children)
DOMUtils.prepend(head.children[0], styleElement);
else
DOMUtils.appendChild(head, styleElement);
else {
const body = DOMUtils.getElementsByTagName('body', dom, true, 2)[0];
if (body)
if (body.children)
DOMUtils.prepend(body.children[0], styleElement);
else
DOMUtils.appendChild(body, styleElement);
else
dom.unshift(styleElement);
}
}
return context.delete('rules');
};
function prependElement(parent, element) {
if (parent.children)
DOMUtils.prepend(parent.children[0], element);
else
DOMUtils.appendChild(parent, element);
}
type: ElementType.Style,
name: 'style',
attribs: {},
children: []
};
DOMUtils.appendChild(styleElement, {
type: ElementType.Text,
data: css
});
const head = DOMUtils.getElementsByTagName('head', dom, true, 2)[0];
if (head)
if (head.children)
DOMUtils.prepend(head.children[0], styleElement);
else
DOMUtils.appendChild(head, styleElement);
else {
const body = DOMUtils.getElementsByTagName('body', dom, true, 2)[0];
if (body)
if (body.children)
DOMUtils.prepend(body.children[0], styleElement);
else
DOMUtils.appendChild(body, styleElement);
else
dom.unshift(styleElement);
}
}
return context.delete('rules');
};
module.exports = function appendRules(context) {
const dom = context.dom;
const rules = context.rules;
const compress = context.compress;
if (rules && rules.size) {
const css = stringifyRules(rules, compress);
const styleElement = {
type: ElementType.Style,
name: 'style',
attribs: {},
children: []
};
DOMUtils.appendChild(styleElement, {
type: ElementType.Text,
data: css
});
const head = DOMUtils.getElementsByTagName('head', dom, true, 2)[0];
if (head)
if (head.children)
DOMUtils.prepend(head.children[0], styleElement);
else
DOMUtils.appendChild(head, styleElement);
else {
const body = DOMUtils.getElementsByTagName('body', dom, true, 2)[0];
if (body)
if (body.children)
DOMUtils.prepend(body.children[0], styleElement);
else