@node-projects/web-component-designer 0.1.61 → 0.1.62

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,23 @@ 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.includes(DesignerCanvas.cssprefixConstant)) {
120
+ sel += p;
121
+ continue;
122
+ }
123
+ if (sel)
124
+ sel += ',';
125
+ sel += DesignerCanvas.cssprefixConstant + p.trimStart();
119
126
  }
120
- if (sel)
121
- sel += ',';
122
- sel += DesignerCanvas.cssprefixConstant + p.trimStart();
127
+ }
128
+ else {
129
+ sel = rule.selectorText;
123
130
  }
124
131
  t += sel;
125
132
  let cssText = rule.style.cssText;
@@ -131,10 +138,12 @@ export class AbstractStylesheetService {
131
138
  cssText += e[0] + ':' + e[1].toString() + ';';
132
139
  }
133
140
  }
134
- t += '{' + cssText + '}';
135
- /*if (rule.cssRules) {
136
- t += rule.cssText.split(rule.conditionText)[0] + rule.conditionText + " { " + this.traverseAndCollectRules(rule) + " }";
137
- }*/
141
+ t += '{' + cssText;
142
+ if (rule.cssRules?.length) {
143
+ const part = this.traverseAndCollectRules(rule, true);
144
+ t += part;
145
+ }
146
+ t += '}';
138
147
  }
139
148
  }
140
149
  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.62",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "author": "jochen.kuehner@gmx.de",