Skip to content
This plugin is new and currently in beta. For the stable version, please use the previous version of the plugin.

ImmutableCssNode

Union type representing immutable CSS nodes in email templates.

typescript
type ImmutableCssNode = ImmutableCssCommentNode 
    | ImmutableCssAttributeNode 
    | ImmutableCssRuleNode 
    | ImmutableCssDocumentNode;

Description

ImmutableCssNode is a union type that represents any CSS node in the stylesheet structure. It can be a comment, attribute (property), rule, or document node. This type is used throughout the API for CSS manipulation and querying.

Import

typescript
import { ImmutableCssNode } from '@stripoinc/ui-editor-extensions';

Type Members

TypeDescription
ImmutableCssCommentNodeCSS comment nodes
ImmutableCssAttributeNodeCSS properties within rules
ImmutableCssRuleNodeCSS rules with selectors
ImmutableCssDocumentNodeCSS document root or @media blocks

Base Inheritance

All CSS nodes extend from:

Type Guards and Casting

Determining Node Type

typescript
function processCssNode(node: ImmutableCssNode) {
    const type = node.getType();
    
    switch(type) {
        case 'rule':
            const rule = node.asRule();
            console.log(`Rule: ${rule.getSelector()}`);
            break;
        case 'attr':
            const attr = node.asAttribute();
            console.log(`Property: ${attr.getAttributeName()}: ${attr.getAttributeValue()}`);
            break;
        case 'comment':
            const comment = node.asComment();
            console.log(`Comment: ${comment.getTextContent()}`);
            break;
        case 'document':
        case 'media':
            const doc = node.asDocument();
            console.log('Document or media query node');
            break;
    }
}