class postcss.Declaration
extends Node
Re-export
import { postcss } from "https://deno.land/x/bundler@0.6.5/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
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
The declaration's property name.
const root = postcss.parse('a { color: black }')
const decl = root.first.first
decl.prop //=> 'color'
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'
Methods
clone(overrides?: Partial<DeclarationProps>): this
cloneAfter(overrides?: Partial<DeclarationProps>): this
cloneBefore(overrides?: Partial<DeclarationProps>): this