Skip to main content
Module

x/bundler/deps.ts>postcss.Rule

A Bundler with the web in mind.
Latest
class postcss.Rule
extends Container
Re-export
import { postcss } from "https://deno.land/x/bundler@0.9.0/deps.ts";
const { Rule } = postcss;

Represents a CSS rule: a selector followed by a declaration block.

Once (root, { Rule }) {
  let a = new Rule({ selector: 'a' })
  a.append(…)
  root.append(a)
}
const root = postcss.parse('a{}')
const rule = root.first
rule.type       //=> 'rule'
rule.toString() //=> 'a{}'

Constructors

new
Rule(defaults?: RuleProps)

Properties

parent: Container | undefined
raws: RuleRaws
selector: string

The rule’s full selector represented as a string.

const root = postcss.parse('a, b { }')
const rule = root.first
rule.selector //=> 'a, b'
selectors: string[]

An array containing the rule’s individual selectors. Groups of selectors are split at commas.

const root = postcss.parse('a, b { }')
const rule = root.first

rule.selector  //=> 'a, b'
rule.selectors //=> ['a', 'b']

rule.selectors = ['a', 'strong']
rule.selector //=> 'a, strong'
type: "rule"

Methods

assign(overrides: object | RuleProps): this
clone(overrides?: Partial<RuleProps>): this
cloneAfter(overrides?: Partial<RuleProps>): this
cloneBefore(overrides?: Partial<RuleProps>): this