|
|
@ -14,10 +14,10 @@ class Rule {
|
|
|
|
node: Node;
|
|
|
|
node: Node;
|
|
|
|
parent: Atrule;
|
|
|
|
parent: Atrule;
|
|
|
|
|
|
|
|
|
|
|
|
constructor(node: Node, parent?: Atrule) {
|
|
|
|
constructor(node: Node, stylesheet, parent?: Atrule) {
|
|
|
|
this.node = node;
|
|
|
|
this.node = node;
|
|
|
|
this.parent = parent;
|
|
|
|
this.parent = parent;
|
|
|
|
this.selectors = node.selector.children.map((node: Node) => new Selector(node));
|
|
|
|
this.selectors = node.selector.children.map((node: Node) => new Selector(node, stylesheet));
|
|
|
|
this.declarations = node.block.children.map((node: Node) => new Declaration(node));
|
|
|
|
this.declarations = node.block.children.map((node: Node) => new Declaration(node));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -274,6 +274,8 @@ export default class Stylesheet {
|
|
|
|
children: (Rule|Atrule)[];
|
|
|
|
children: (Rule|Atrule)[];
|
|
|
|
keyframes: Map<string, string>;
|
|
|
|
keyframes: Map<string, string>;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nodesWithCssClass: Set<Node>;
|
|
|
|
|
|
|
|
|
|
|
|
constructor(source: string, parsed: Parsed, filename: string, cascade: boolean, dev: boolean) {
|
|
|
|
constructor(source: string, parsed: Parsed, filename: string, cascade: boolean, dev: boolean) {
|
|
|
|
this.source = source;
|
|
|
|
this.source = source;
|
|
|
|
this.parsed = parsed;
|
|
|
|
this.parsed = parsed;
|
|
|
@ -284,6 +286,8 @@ export default class Stylesheet {
|
|
|
|
this.children = [];
|
|
|
|
this.children = [];
|
|
|
|
this.keyframes = new Map();
|
|
|
|
this.keyframes = new Map();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.nodesWithCssClass = new Set();
|
|
|
|
|
|
|
|
|
|
|
|
if (parsed.css && parsed.css.children.length) {
|
|
|
|
if (parsed.css && parsed.css.children.length) {
|
|
|
|
this.id = `svelte-${hash(parsed.css.content.styles)}`;
|
|
|
|
this.id = `svelte-${hash(parsed.css.content.styles)}`;
|
|
|
|
|
|
|
|
|
|
|
@ -322,7 +326,7 @@ export default class Stylesheet {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (node.type === 'Rule') {
|
|
|
|
if (node.type === 'Rule') {
|
|
|
|
const rule = new Rule(node, currentAtrule);
|
|
|
|
const rule = new Rule(node, this, currentAtrule);
|
|
|
|
stack.push(rule);
|
|
|
|
stack.push(rule);
|
|
|
|
|
|
|
|
|
|
|
|
if (currentAtrule) {
|
|
|
|
if (currentAtrule) {
|
|
|
@ -353,7 +357,7 @@ export default class Stylesheet {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (this.cascade) {
|
|
|
|
if (this.cascade) {
|
|
|
|
if (stack.length === 0) node.addCssClass();
|
|
|
|
if (stack.length === 0) this.nodesWithCssClass.add(node);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -363,6 +367,12 @@ export default class Stylesheet {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reify() {
|
|
|
|
|
|
|
|
this.nodesWithCssClass.forEach((node: Node) => {
|
|
|
|
|
|
|
|
node.addCssClass();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
render(cssOutputFilename: string, shouldTransformSelectors: boolean) {
|
|
|
|
render(cssOutputFilename: string, shouldTransformSelectors: boolean) {
|
|
|
|
if (!this.hasStyles) {
|
|
|
|
if (!this.hasStyles) {
|
|
|
|
return { css: null, cssMap: null };
|
|
|
|
return { css: null, cssMap: null };
|
|
|
@ -438,4 +448,4 @@ export default class Stylesheet {
|
|
|
|
child.warnOnUnusedSelector(handler);
|
|
|
|
child.warnOnUnusedSelector(handler);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|