UNPKG

3.71 kBTypeScriptView Raw
1export as namespace CSSOM;
2
3/**
4 * Produces a deep copy of stylesheet — the instance variables of stylesheet are copied recursively.
5 */
6export function clone(stylesheet: CSSStyleSheet): CSSStyleSheet;
7
8export function parse(token: string): CSSStyleSheet;
9
10export abstract class StyleSheet {
11 parentStyleSheet: StyleSheet | null;
12}
13
14export class CSSStyleSheet extends StyleSheet {
15 cssRules: CSSRule[];
16
17 deleteRule(index: number): void;
18 insertRule(rule: string, index?: number): number;
19}
20
21export abstract class CSSRule {
22 readonly cssText: string;
23
24 parentRule: CSSRule | null;
25 parentStyleSheet: StyleSheet | null;
26
27 readonly type: number;
28}
29
30export namespace CSSRule {
31 /** @deprecated Obsolete */
32 const UNKNOWN_RULE = 0;
33 const STYLE_RULE = 1;
34 /** @deprecated Obsolete */
35 const CHARSET_RULE = 2;
36 const IMPORT_RULE = 3;
37 const MEDIA_RULE = 4;
38 const FONT_FACE_RULE = 5;
39 const PAGE_RULE = 6;
40 const KEYFRAMES_RULE = 7;
41 const KEYFRAME_RULE = 8;
42 const MARGIN_RULE = 9;
43 const NAMESPACE_RULE = 10;
44 const COUNTER_STYLE_RULE = 11;
45 const SUPPORTS_RULE = 12;
46 const DOCUMENT_RULE = 13;
47 const FONT_FEATURE_VALUES_RULE = 14;
48 const VIEWPORT_RULE = 15;
49 const REGION_STYLE_RULE = 16;
50}
51
52export class CSSStyleRule extends CSSRule {
53 cssText: string;
54
55 selectorText: string;
56 style: CSSStyleDeclaration;
57
58 static parse(ruleText: any): any;
59 readonly type: 1;
60}
61
62export class CSSImportRule extends CSSRule {
63 cssText: string;
64
65 href: string;
66 media: MediaList;
67 styleSheet: CSSStyleSheet;
68
69 readonly type: 3;
70}
71
72export class CSSMediaRule extends CSSRule {
73 media: MediaList;
74 cssRules: CSSRule[];
75
76 readonly type: 4;
77}
78
79export class CSSFontFaceRule extends CSSRule {
80 style: CSSStyleDeclaration;
81
82 readonly type: 5;
83}
84
85export class CSSKeyframesRule extends CSSRule {
86 name: string;
87 cssRules: CSSRule[];
88
89 readonly type: 7;
90}
91
92export class CSSKeyframeRule extends CSSRule {
93 keyText: string;
94 style: CSSStyleDeclaration;
95
96 readonly type: 8;
97}
98
99export class CSSSupportsRule extends CSSRule {
100 conditionText: string;
101 cssRules: CSSRule[];
102
103 readonly type: 12;
104}
105
106/** @deprecated Removed from spec */
107export class CSSDocumentRule extends CSSRule {
108 matcher: MatcherList;
109 cssRules: CSSRule[];
110
111 readonly type: 13;
112}
113
114/**
115 * @deprecated Legacy Shadow DOM v0
116 * @see https://www.w3.org/TR/2013/WD-shadow-dom-20130514/#host-at-rule
117 */
118export class CSSHostRule extends CSSRule {
119 cssRules: CSSRule[];
120
121 readonly type: 1001;
122}
123
124export class CSSStyleDeclaration {
125 cssText: string;
126 length: number;
127 parentRule: CSSRule | null;
128
129 getPropertyPriority(name: string): string;
130 getPropertyValue(name: string): string;
131 removeProperty(name: string): string;
132 setProperty(name: string, value: string | null, priority?: string | null): void;
133
134 [index: number]: string;
135}
136
137/** @deprecated */
138export class CSSValue {
139 /** @unsupported The getter and setter are currently unimplemented and throw unconditionally. */
140 cssText: string;
141}
142
143/** @deprecated */
144export class CSSValueExpression extends CSSValue {
145 constructor(token: string, idx: number);
146
147 parse(): { error: any } | { idx: number; expression: string };
148}
149
150/** @deprecated Removed from spec */
151export class MatcherList {
152 length: number;
153 matcherText: string;
154
155 appendMatcher(matcher: string): void;
156 deleteMatcher(matcher: string): void;
157
158 [index: number]: string;
159}
160
161export class MediaList {
162 length: number;
163 mediaText: string;
164
165 appendMedium(medium: string): void;
166 deleteMedium(medium: string): void;
167
168 [index: number]: string;
169}