Constructor
new Sheet(url, hooksopt)
Create a Sheet instance.
Create a Sheet instance.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
url |
string | The base URL for resolving relative paths. |
|
hooks |
Object |
<optional> |
Optional custom hook object. |
- Source:
Members
text
- Source:
text
- Source:
Methods
addScope(ast, id)
Scopes all selectors by prepending an ID selector.
Scopes all selectors by prepending an ID selector.
Parameters:
Name | Type | Description |
---|---|---|
ast |
Object | CSS AST. |
id |
string | Scope ID. |
- Source:
atrules(ast)
Processes all at-rules and triggers relevant hooks.
Processes all at-rules and triggers relevant hooks.
Parameters:
Name | Type | Description |
---|---|---|
ast |
Object | CSS AST. |
- Source:
declarations(ruleNode, ruleItem, rulelist)
Triggers onDeclaration and onContent hooks for declarations.
Triggers onDeclaration and onContent hooks for declarations.
Parameters:
Name | Type | Description |
---|---|---|
ruleNode |
Object | |
ruleItem |
* | |
rulelist |
* |
- Source:
getNamedPageSelectors(ast) → {Object}
Extracts named @page selectors and modifies them.
Extracts named @page selectors and modifies them.
Parameters:
Name | Type | Description |
---|---|---|
ast |
Object | CSS AST. |
- Source:
Returns:
Named page selectors with their CSS selectors.
- Type
- Object
imports(node, item, list)
Processes @import rules, adds valid URLs to this.imported
, and removes them from AST.
Processes @import rules, adds valid URLs to this.imported
, and removes them from AST.
Parameters:
Name | Type | Description |
---|---|---|
node |
Object | |
item |
* | |
list |
* |
- Source:
insertRule(rule) → {Object}
Inserts a new CSS rule into the AST.
Inserts a new CSS rule into the AST.
Parameters:
Name | Type | Description |
---|---|---|
rule |
Object | A csstree rule node. |
- Source:
Returns:
The inserted rule node.
- Type
- Object
onSelector(ruleNode, ruleItem, rulelist)
Handles selector and pseudo-selector hooks.
Handles selector and pseudo-selector hooks.
Parameters:
Name | Type | Description |
---|---|---|
ruleNode |
Object | |
ruleItem |
* | |
rulelist |
* |
- Source:
(async) parse(text) → {Promise.<Object>}
Parses a CSS string and returns the AST.
Parses a CSS string and returns the AST.
Parameters:
Name | Type | Description |
---|---|---|
text |
string | Raw CSS text to parse. |
- Source:
Returns:
Parsed CSS AST.
- Type
- Promise.<Object>
replaceIds(ast)
Converts ID selectors to [data-id="..."] format.
Converts ID selectors to [data-id="..."] format.
Parameters:
Name | Type | Description |
---|---|---|
ast |
Object | CSS AST. |
- Source:
replaceUrls(ast)
Resolves relative URLs in url()
functions.
Resolves relative URLs in url()
functions.
Parameters:
Name | Type | Description |
---|---|---|
ast |
Object | CSS AST. |
- Source:
rules(ast)
Processes rule nodes and triggers related hooks.
Processes rule nodes and triggers related hooks.
Parameters:
Name | Type | Description |
---|---|---|
ast |
Object | CSS AST. |
- Source:
toString(astopt) → {string}
Generates a CSS string from AST.
Generates a CSS string from AST.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
ast |
Object |
<optional> |
AST to stringify. Defaults to internal AST. |
- Source:
Returns:
CSS code as string.
- Type
- string
urls(ast)
Triggers onUrl hook for each URL node.
Triggers onUrl hook for each URL node.
Parameters:
Name | Type | Description |
---|---|---|
ast |
Object | CSS AST. |
- Source: