@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
- targetMap.set(stylesheet.name, {
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
- for (let p of parts) {
114
- if (p == ':host')
115
- sel += DesignerCanvas.cssprefixConstant;
116
- else if (p.includes(DesignerCanvas.cssprefixConstant)) {
117
- sel += p;
118
- continue;
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
- if (sel)
121
- sel += ',';
122
- sel += DesignerCanvas.cssprefixConstant + p.trimStart();
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
- /*if (rule.cssRules) {
136
- t += rule.cssText.split(rule.conditionText)[0] + rule.conditionText + " { " + this.traverseAndCollectRules(rule) + " }";
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;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "description": "A UI designer for Polymer apps",
3
3
  "name": "@node-projects/web-component-designer",
4
- "version": "0.1.61",
4
+ "version": "0.1.63",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "jochen.kuehner@gmx.de",