@node-projects/web-component-designer 0.1.61 → 0.1.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -36,15 +36,17 @@ export class AbstractStylesheetService {
|
|
|
36
36
|
else if (stylesheets != null) {
|
|
37
37
|
targetMap.clear();
|
|
38
38
|
for (let stylesheet of stylesheets) {
|
|
39
|
+
let ast = null;
|
|
39
40
|
try {
|
|
40
|
-
|
|
41
|
-
stylesheet: stylesheet,
|
|
42
|
-
ast: await this.internalParse(stylesheet.content)
|
|
43
|
-
});
|
|
41
|
+
ast = await this.internalParse(stylesheet.content);
|
|
44
42
|
}
|
|
45
43
|
catch (err) {
|
|
46
44
|
console.warn("error parsing stylesheet", stylesheet, err);
|
|
47
45
|
}
|
|
46
|
+
targetMap.set(stylesheet.name, {
|
|
47
|
+
stylesheet: stylesheet,
|
|
48
|
+
ast: ast
|
|
49
|
+
});
|
|
48
50
|
}
|
|
49
51
|
if (targetMap == this._stylesheets)
|
|
50
52
|
this.stylesheetsChanged.emit();
|
|
@@ -94,7 +96,7 @@ export class AbstractStylesheetService {
|
|
|
94
96
|
}
|
|
95
97
|
return style;
|
|
96
98
|
}
|
|
97
|
-
static traverseAndCollectRules(ruleContainer) {
|
|
99
|
+
static traverseAndCollectRules(ruleContainer, noPatch = false) {
|
|
98
100
|
let t = '';
|
|
99
101
|
for (let rule of ruleContainer.cssRules) {
|
|
100
102
|
if ((rule instanceof CSSContainerRule
|
|
@@ -108,18 +110,25 @@ export class AbstractStylesheetService {
|
|
|
108
110
|
t += rule.cssText;
|
|
109
111
|
}
|
|
110
112
|
else if (rule instanceof CSSStyleRule) {
|
|
111
|
-
let parts = rule.selectorText.split(',');
|
|
112
113
|
let sel = "";
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
114
|
+
if (!noPatch) {
|
|
115
|
+
let parts = rule.selectorText.split(',');
|
|
116
|
+
for (let p of parts) {
|
|
117
|
+
if (p == ':host')
|
|
118
|
+
sel += DesignerCanvas.cssprefixConstant;
|
|
119
|
+
else if (p == ':root')
|
|
120
|
+
sel += p;
|
|
121
|
+
else if (p.includes(DesignerCanvas.cssprefixConstant)) {
|
|
122
|
+
sel += p;
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (sel)
|
|
126
|
+
sel += ',';
|
|
127
|
+
sel += DesignerCanvas.cssprefixConstant + p.trimStart();
|
|
119
128
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
sel
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
sel = rule.selectorText;
|
|
123
132
|
}
|
|
124
133
|
t += sel;
|
|
125
134
|
let cssText = rule.style.cssText;
|
|
@@ -131,10 +140,12 @@ export class AbstractStylesheetService {
|
|
|
131
140
|
cssText += e[0] + ':' + e[1].toString() + ';';
|
|
132
141
|
}
|
|
133
142
|
}
|
|
134
|
-
t += '{' + cssText
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
143
|
+
t += '{' + cssText;
|
|
144
|
+
if (rule.cssRules?.length) {
|
|
145
|
+
const part = this.traverseAndCollectRules(rule, true);
|
|
146
|
+
t += part;
|
|
147
|
+
}
|
|
148
|
+
t += '}';
|
|
138
149
|
}
|
|
139
150
|
}
|
|
140
151
|
return t;
|