• Extracts and removes normal stylesheets from the trees of the given elements. style or link elements with 'ski-p' attributes, will be ignored in the processing. Also those with kee-p attributes will be processed but they will not be removed from the tree.

    Use the exported popAttrs object to configure the attribute names for skip and keep if the afore-mentioned defaults will not suffice for your use case.

    Parameters

    • Rest ...elements: Element[]

      The elements at the top of all trees to process

    Returns any

    Example

    import { popStyles } from 'deleight/css'
    const markup =
    `<div>
    <style>${css}</style>
    <div>
    <link rel="stylesheet" href="page.css">
    </div>
    <style>${css}</style>
    <div><div><link rel="stylesheet" href="page.css"></div></div>
    </div>`;
    const tree = document.createElement('div');
    const styles = [...popStyles(tree)];
    // styles the contains: [CSSStyleSheet, Promise<CSSStyleSheet>,
    CSSStyleSheet, Promise<CSSStyleSheet>]