@sola-air-ui/compiler 1.5.3 → 1.5.4
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.
- package/package.json +1 -1
- package/src/check-cli.js +0 -0
- package/src/check.js +1 -1
- package/src/index.js +8 -8
package/package.json
CHANGED
package/src/check-cli.js
CHANGED
|
File without changes
|
package/src/check.js
CHANGED
|
@@ -105,7 +105,7 @@ export function checkSource(source, filename = 'component.sola') {
|
|
|
105
105
|
add(at, 'error', 'SOLA001', '`{:else if}` is missing a condition. It renders as literal text.');
|
|
106
106
|
}
|
|
107
107
|
} else {
|
|
108
|
-
add(at, 'error', 'SOLA001', '`{:else}`
|
|
108
|
+
add(at, 'error', 'SOLA001', '`{:else}` has extra text after it (use `{:else}` or `{:else if <condition>}`). It renders as literal text.');
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
}
|
package/src/index.js
CHANGED
|
@@ -73,9 +73,9 @@ function addScopeToCompound(compound, scopeHash) {
|
|
|
73
73
|
// :global(body) → body
|
|
74
74
|
// The scope class always goes on the last compound that is not global.
|
|
75
75
|
function scopeSelector(selector, scopeHash) {
|
|
76
|
-
const
|
|
76
|
+
const pieces = []; // alternating compounds and combinators
|
|
77
77
|
let depth = 0, cur = '', comb = '';
|
|
78
|
-
const flushCompound = () => { if (cur) {
|
|
78
|
+
const flushCompound = () => { if (cur) { pieces.push({ compound: cur }); cur = ''; } };
|
|
79
79
|
for (let i = 0; i < selector.length; i++) {
|
|
80
80
|
const c = selector[i];
|
|
81
81
|
if (c === '(' || c === '[') depth++;
|
|
@@ -85,15 +85,15 @@ function scopeSelector(selector, scopeHash) {
|
|
|
85
85
|
comb += c;
|
|
86
86
|
continue;
|
|
87
87
|
}
|
|
88
|
-
if (comb) {
|
|
88
|
+
if (comb) { pieces.push({ comb }); comb = ''; }
|
|
89
89
|
cur += c;
|
|
90
90
|
}
|
|
91
91
|
flushCompound();
|
|
92
|
-
if (comb)
|
|
92
|
+
if (comb) pieces.push({ comb });
|
|
93
93
|
|
|
94
94
|
let last = -1;
|
|
95
|
-
for (let i = 0; i <
|
|
96
|
-
const t =
|
|
95
|
+
for (let i = 0; i < pieces.length; i++) {
|
|
96
|
+
const t = pieces[i];
|
|
97
97
|
if (t.compound === undefined) continue;
|
|
98
98
|
const m = t.compound.match(/^:global\(([\s\S]*)\)$/);
|
|
99
99
|
// A comma list must stay grouped, or `.a :global(.x, .y)` would turn into
|
|
@@ -105,8 +105,8 @@ function scopeSelector(selector, scopeHash) {
|
|
|
105
105
|
t.global = true;
|
|
106
106
|
} else { last = i; }
|
|
107
107
|
}
|
|
108
|
-
if (last >= 0)
|
|
109
|
-
return
|
|
108
|
+
if (last >= 0) pieces[last].compound = addScopeToCompound(pieces[last].compound, scopeHash);
|
|
109
|
+
return pieces.map(t => t.compound ?? t.comb).join('');
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
function scopeSelectorList(selector, scopeHash) {
|