single-file-core 1.0.59 → 1.0.61
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.
|
@@ -174,12 +174,13 @@ function getMatchedElementsSelector(doc, selectorInfo, styles, matchedElementsCa
|
|
|
174
174
|
}
|
|
175
175
|
|
|
176
176
|
function getFilteredSelector(selector, selectorText) {
|
|
177
|
-
const namespaceSeparatorIndex = selectorText.lastIndexOf("|");
|
|
178
|
-
if (namespaceSeparatorIndex > -1) {
|
|
179
|
-
return selectorText.substring(namespaceSeparatorIndex + 1);
|
|
180
|
-
}
|
|
181
177
|
const removedSelectors = [];
|
|
178
|
+
let namespaceFound;
|
|
182
179
|
selector = { data: cssTree.parse(cssTree.generate(selector.data), { context: "selector" }) };
|
|
180
|
+
filterNamespace(selector);
|
|
181
|
+
if (namespaceFound) {
|
|
182
|
+
selectorText = cssTree.generate(selector.data).trim();
|
|
183
|
+
}
|
|
183
184
|
filterPseudoClasses(selector);
|
|
184
185
|
if (removedSelectors.length) {
|
|
185
186
|
removedSelectors.forEach(({ parentSelector, selector }) => {
|
|
@@ -205,6 +206,18 @@ function getFilteredSelector(selector, selectorText) {
|
|
|
205
206
|
}
|
|
206
207
|
}
|
|
207
208
|
|
|
209
|
+
function filterNamespace(selector) {
|
|
210
|
+
if (selector.data.children) {
|
|
211
|
+
for (let childSelector = selector.data.children.head; childSelector; childSelector = childSelector.next) {
|
|
212
|
+
filterNamespace(childSelector);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (selector.data.type == "TypeSelector" && selector.data.name.includes("|")) {
|
|
216
|
+
namespaceFound = true;
|
|
217
|
+
selector.data.name = selector.data.name.substring(selector.data.name.lastIndexOf("|") + 1);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
208
221
|
function testVendorPseudo(selector) {
|
|
209
222
|
const name = selector.data.name;
|
|
210
223
|
return name.startsWith("-") || name.startsWith("\\-");
|
package/package.json
CHANGED
|
@@ -172,12 +172,19 @@ function parse(value) {
|
|
|
172
172
|
throw error("Missing required font-family.");
|
|
173
173
|
}
|
|
174
174
|
font.family = [];
|
|
175
|
-
|
|
175
|
+
let familyName = "";
|
|
176
|
+
while (tokenNode) {
|
|
176
177
|
while (tokenNode && tokenNode.data.type == "Operator" && tokenNode.data.value == ",") {
|
|
177
178
|
tokenNode = tokenNode.next;
|
|
178
179
|
}
|
|
179
|
-
|
|
180
|
-
|
|
180
|
+
while (tokenNode && tokenNode.data.type == "Identifier") {
|
|
181
|
+
familyName += " " + removeQuotes(cssTree.generate(tokenNode.data));
|
|
182
|
+
tokenNode = tokenNode.next;
|
|
183
|
+
}
|
|
184
|
+
familyName = familyName.trim();
|
|
185
|
+
if (familyName) {
|
|
186
|
+
font.family.push(familyName);
|
|
187
|
+
familyName = "";
|
|
181
188
|
}
|
|
182
189
|
}
|
|
183
190
|
return font;
|