Class: PrintMedia

PrintMedia(chunker, polisher, caller)

Handles @media print rules during the stylesheet parsing phase.

  • Extracts CSS rules inside @media print and appends them to the main stylesheet.
  • Removes @media blocks that are neither print, all, nor explicitly ignored.

Constructor

new PrintMedia(chunker, polisher, caller)

Creates an instance of PrintMedia handler.

Creates an instance of PrintMedia handler.

Parameters:
Name Type Description
chunker Object

The chunker instance used for pagination.

polisher Object

The polisher instance that processes stylesheets.

caller Object

The object that coordinates multiple handlers.

Source:

Methods

getMediaName(node) → {Array.<string>}

Extracts all media type names from a @media at-rule node.

Extracts all media type names from a @media at-rule node.

Parameters:
Name Type Description
node Object

The AST node representing a @media at-rule.

Source:
Returns:

An array of media query identifiers (e.g. ["print"], ["screen"]).

Type
Array.<string>

onAtMedia(node, item, list)

Called when a @media at-rule is encountered in the stylesheet.

Called when a @media at-rule is encountered in the stylesheet.

  • If the media type includes print, the rules inside are extracted and appended to the main rule list (i.e. made global).
  • If the media type is unsupported or not needed, the block is removed entirely.
Parameters:
Name Type Description
node Object

The AST node for the @media at-rule.

item Object

The item in the list representing this rule.

list Object

The list of all CSS rules being parsed.

Source: