single-file-core 1.0.59 → 1.0.60

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "single-file-core",
3
- "version": "1.0.59",
3
+ "version": "1.0.60",
4
4
  "description": "SingleFile Core",
5
5
  "author": "Gildas Lormeau",
6
6
  "license": "AGPL-3.0-or-later",