UNPKG

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