How to use the domutils.prepend 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 fb55 / css-select / test / sizzle / selector.js View on Github external
helper.getDOM(str).forEach(function(child) {
                    DomUtils.prepend(elem, child);
                });
            });
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
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
          DOMUtils.appendChild(body, styleElement);
      else
        dom.unshift(styleElement);
    }

  }
  return context.delete('rules');
};