Class: Polisher

Polisher(setupopt)

The Polisher class handles the parsing and insertion of CSS stylesheets, including remote resources and special hooks for processing CSS content.

Constructor

new Polisher(setupopt)

Creates a new Polisher instance.

Creates a new Polisher instance.

Parameters:
Name Type Attributes Default Description
setup boolean <optional>
true

Whether to immediately run setup.

Source:

Members

hooks :Object.<string, Hook>

Type:
  • Object.<string, Hook>
Source:

inserted :Array.<HTMLStyleElement>

Type:
  • Array.<HTMLStyleElement>
Source:

sheets :Array.<Sheet>

Type:
Source:

Methods

(async) add(…sources) → {Promise.<string>}

Adds and processes one or more CSS sources (URLs or inline CSS).

Adds and processes one or more CSS sources (URLs or inline CSS).

Parameters:
Name Type Attributes Description
sources string | Object.<string, string> <repeatable>

URLs or object maps of URLs to CSS strings.

Source:
Returns:
  • The final processed CSS text.
Type
Promise.<string>

(async) convertViaSheet(cssStr, href) → {Promise.<string>}

Converts raw CSS into a Sheet object, parses it, handles imports, and returns the processed CSS string.

Converts raw CSS into a Sheet object, parses it, handles imports, and returns the processed CSS string.

Parameters:
Name Type Description
cssStr string

The raw CSS string.

href string

The source URL for the CSS.

Source:
Returns:
  • The processed CSS text.
Type
Promise.<string>

destroy()

Cleans up all inserted styles and resets the polisher.

Cleans up all inserted styles and resets the polisher.

Source:

insert(text) → {HTMLStyleElement}

Inserts a CSS string into the document inside a

Inserts a CSS string into the document inside a

Sets up the base stylesheet and injects a