esm-styles 0.1.9 → 0.1.10
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.
|
@@ -155,7 +155,10 @@ export const joinSelectorPath = (path) => {
|
|
|
155
155
|
// Compute cartesian product of all segments
|
|
156
156
|
const combos = utils.cartesianProduct(path);
|
|
157
157
|
// Join each combination into a selector string
|
|
158
|
-
return combos.map((parts) => parts.reduce((acc, part) => {
|
|
158
|
+
return combos.map((parts) => parts.reduce((acc, part, idx) => {
|
|
159
|
+
// Check if previous part is a root selector
|
|
160
|
+
const prev = idx > 0 ? parts[idx - 1] : null;
|
|
161
|
+
const isPrevRoot = prev && (prev === ':root' || prev.startsWith(':root.'));
|
|
159
162
|
if (part.startsWith('__')) {
|
|
160
163
|
return acc + (acc ? ' ' : '') + '.' + part.slice(2);
|
|
161
164
|
}
|
|
@@ -185,7 +188,11 @@ export const joinSelectorPath = (path) => {
|
|
|
185
188
|
return acc + (acc ? ' ' : '') + match[1] + '.' + match[2];
|
|
186
189
|
}
|
|
187
190
|
}
|
|
188
|
-
// Not a tag, not a special selector: treat as class
|
|
191
|
+
// Not a tag, not a special selector: treat as class or custom element
|
|
192
|
+
// If previous part is a root selector, insert a space
|
|
193
|
+
if (isPrevRoot) {
|
|
194
|
+
return acc + ' ' + '.' + part;
|
|
195
|
+
}
|
|
189
196
|
return acc + (acc ? '' : '') + '.' + part;
|
|
190
197
|
}, ''));
|
|
191
198
|
};
|