declaration.d.ts
2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import Node from './node.js'
interface DeclarationRaws {
/**
* The space symbols before the node. It also stores `*`
* and `_` symbols before the declaration (IE hack).
*/
before?: string
/**
* The symbols between the property and value for declarations.
*/
between?: string
/**
* The content of the important statement, if it is not just `!important`.
*/
important?: string
/**
* Declaration value with comments.
*/
value: {
value: string
raw: string
}
}
export interface DeclarationProps {
prop: string
value: string
raws?: DeclarationRaws
}
/**
* Represents a CSS declaration.
*
* ```js
* Once (root, { Declaration }) {
* let color = new Declaration({ prop: 'color', value: 'black' })
* root.append(color)
* }
* ```
*
* ```js
* const root = postcss.parse('a { color: black }')
* const decl = root.first.first
* decl.type //=> 'decl'
* decl.toString() //=> ' color: black'
* ```
*/
export default class Declaration extends Node {
type: 'decl'
raws: DeclarationRaws
/**
* The declaration's property name.
*
* ```js
* const root = postcss.parse('a { color: black }')
* const decl = root.first.first
* decl.prop //=> 'color'
* ```
*/
prop: 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).
*
* ```js
* const root = postcss.parse('a { color: black }')
* const decl = root.first.first
* decl.value //=> 'black'
* ```
*/
value: string
/**
* `true` if the declaration has an `!important` annotation.
*
* ```js
* const root = postcss.parse('a { color: black !important; color: red }')
* root.first.first.important //=> true
* root.first.last.important //=> undefined
* ```
*/
important: boolean
/**
* `true` if declaration is declaration of CSS Custom Property
* or Sass variable.
*
* ```js
* const root = postcss.parse(':root { --one: 1 }')
* let one = root.first.first
* one.variable //=> true
* ```
*
* ```js
* const root = postcss.parse('$one: 1')
* let one = root.first
* one.variable //=> true
* ```
*/
variable: boolean
constructor(defaults?: DeclarationProps)
clone(overrides?: Partial<DeclarationProps>): this
cloneBefore(overrides?: Partial<DeclarationProps>): this
cloneAfter(overrides?: Partial<DeclarationProps>): this
}