Skip to main content
Module

x/bundler/deps.ts>postcss.Declaration

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

Represents a CSS declaration.

Once (root, { Declaration }) {
  let color = new Declaration({ prop: 'color', value: 'black' })
  root.append(color)
}
const root = postcss.parse('a { color: black }')
const decl = root.first.first
decl.type       //=> 'decl'
decl.toString() //=> ' color: black'

Constructors

new
Declaration(defaults?: DeclarationProps)

Properties

important: boolean

true if the declaration has an !important annotation.

const root = postcss.parse('a { color: black !important; color: red }')
root.first.first.important //=> true
root.first.last.important  //=> undefined
parent: Container | undefined
prop: string

The declaration's property name.

const root = postcss.parse('a { color: black }')
const decl = root.first.first
decl.prop //=> 'color'
raws: DeclarationRaws
type: "decl"
value: string

The declaration’s value.

This value will be cleaned of comments. If the source value contained comments, those comments will be available in the raws property. If you have not changed the value, the result of decl.toString() will include the original raws value (comments and all).

const root = postcss.parse('a { color: black }')
const decl = root.first.first
decl.value //=> 'black'
variable: boolean

true if declaration is declaration of CSS Custom Property or Sass variable.

const root = postcss.parse(':root { --one: 1 }')
let one = root.first.first
one.variable //=> true
const root = postcss.parse('$one: 1')
let one = root.first
one.variable //=> true

Methods

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