How to use the domutils.appendChild function in domutils

To help you get started, we’ve selected a few domutils 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 superfly / fly / packages / v8env / src / document.ts View on Github external
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)
  }
}
github superfly / fly / packages / v8env / src / document.ts View on Github external
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)
  }
}
github fb55 / css-select / test / sizzle / selector.js View on Github external
dom.forEach(function(child) {
                DomUtils.appendChild(elem, child);
            });
            return this;
github broadly / css-inliner / lib / add_rules.js View on Github external
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;
}
github broadly / css-inliner / lib / append_rules.js View on Github external
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');
};
github broadly / css-inliner / lib / add_rules.js View on Github external
function prependElement(parent, element) {
  if (parent.children)
    DOMUtils.prepend(parent.children[0], element);
  else
    DOMUtils.appendChild(parent, element);
}
github broadly / css-inliner / lib / append_rules.js View on Github external
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');
};
github broadly / css-inliner / lib / append_rules.js View on Github external
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