Class: TargetCounters

TargetCounters(chunker, polisher, caller)

Handler for processing CSS target-counter() functions.

Parses CSS rules using target-counter(), replaces them with CSS counters, and dynamically manages counter-reset rules based on page layout.

This allows counters to track values of elements targeted via attributes, supporting complex page-based counters in paged media.

Constructor

new TargetCounters(chunker, polisher, caller)

Creates an instance of TargetCounters.

Creates an instance of TargetCounters.

Parameters:
Name Type Description
chunker Object

The chunker instance managing pagination.

polisher Object

The polisher instance responsible for CSS injection and post-processing.

caller Object

The caller or controller managing this handler.

Source:

Extends

  • Handler

Members

counterTargets :Object.<string, Object>

Stores parsed target counter definitions keyed by selector.

Stores parsed target counter definitions keyed by selector.

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

styleSheet :CSSStyleSheet

Reference to the stylesheet where counter rules will be inserted.

Reference to the stylesheet where counter rules will be inserted.

Type:
  • CSSStyleSheet
Source:

Methods

afterPageLayout(fragment, page, breakToken, chunker)

Called after page layout to update CSS rules for counters targeting elements in the pages.

Called after page layout to update CSS rules for counters targeting elements in the pages. Inserts CSS rules dynamically to reset counters on elements matching the target selectors.

Parameters:
Name Type Description
fragment DocumentFragment

The fragment of the current page.

page Object

The page object (unused here).

breakToken Object

The pagination break token (unused here).

chunker Object

The chunker instance containing the pagesArea DOM.

Source:

onContent(funcNode, fItem, fList, declaration, rule)

Processes CSS content function nodes to detect and handle target-counter() functions.

Processes CSS content function nodes to detect and handle target-counter() functions. Replaces the function with a CSS counter variable and stores necessary metadata.

Parameters:
Name Type Description
funcNode Object

The CSS function node representing target-counter().

fItem Object

The current function node item (unused).

fList Object

The function list (unused).

declaration Object

The CSS declaration node.

rule Object

The CSS rule node containing the declaration.

Source: