@markuplint/selector 4.0.0-dev.28 → 4.0.0-rc.0
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/LICENSE +1 -1
- package/lib/match-selector.js +22 -30
- package/lib/regex-selector-matches.d.ts +1 -1
- package/lib/regex-selector-matches.js +3 -0
- package/package.json +8 -8
package/LICENSE
CHANGED
package/lib/match-selector.js
CHANGED
|
@@ -186,42 +186,34 @@ el, selector) {
|
|
|
186
186
|
tagSelector = el.localName;
|
|
187
187
|
specificity[2] = 1;
|
|
188
188
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
const
|
|
192
|
-
|
|
193
|
-
const matchedAttrName = regexSelectorMatches(
|
|
189
|
+
const isPure = isPureHTMLElement(el);
|
|
190
|
+
if (selector.attrName || selector.attrValue) {
|
|
191
|
+
const matchedAttrList = [...el.attributes]
|
|
192
|
+
.map(attr => {
|
|
193
|
+
const matchedAttrName = regexSelectorMatches(selector.attrName, attr.name, isPure);
|
|
194
|
+
if (selector.attrName && !matchedAttrName) {
|
|
195
|
+
return null;
|
|
196
|
+
}
|
|
197
|
+
const matchedAttrValue = regexSelectorMatches(selector.attrValue, attr.value, isPure);
|
|
198
|
+
if (selector.attrValue && !matchedAttrValue) {
|
|
199
|
+
return null;
|
|
200
|
+
}
|
|
194
201
|
if (matchedAttrName) {
|
|
195
202
|
delete matchedAttrName.$0;
|
|
196
|
-
data = {
|
|
197
|
-
...data,
|
|
198
|
-
...matchedAttrName,
|
|
199
|
-
};
|
|
200
|
-
specifiedAttr.set(attrName, '');
|
|
201
203
|
}
|
|
202
|
-
return matchedAttrName;
|
|
203
|
-
});
|
|
204
|
-
if (!matchedAttrNameList.some(_ => !!_)) {
|
|
205
|
-
matched = false;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
if (selector.attrValue) {
|
|
209
|
-
const selectorAttrValue = selector.attrValue;
|
|
210
|
-
const matchedAttrValueList = [...el.attributes].map(attr => {
|
|
211
|
-
const attrName = attr.name;
|
|
212
|
-
const attrValue = attr.value;
|
|
213
|
-
const matchedAttrValue = regexSelectorMatches(selectorAttrValue, attrValue, isPureHTMLElement(el));
|
|
214
204
|
if (matchedAttrValue) {
|
|
215
205
|
delete matchedAttrValue.$0;
|
|
216
|
-
data = {
|
|
217
|
-
...data,
|
|
218
|
-
...matchedAttrValue,
|
|
219
|
-
};
|
|
220
|
-
specifiedAttr.set(attrName, attrValue);
|
|
221
206
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
207
|
+
data = {
|
|
208
|
+
...data,
|
|
209
|
+
...matchedAttrName,
|
|
210
|
+
...matchedAttrValue,
|
|
211
|
+
};
|
|
212
|
+
specifiedAttr.set(attr.name, matchedAttrValue ? attr.value : '');
|
|
213
|
+
return matchedAttrValue ?? matchedAttrName ?? null;
|
|
214
|
+
})
|
|
215
|
+
.filter((a) => !!a);
|
|
216
|
+
if (matchedAttrList.length === 0) {
|
|
225
217
|
matched = false;
|
|
226
218
|
}
|
|
227
219
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/selector",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-rc.0",
|
|
4
4
|
"description": "Extended W3C Selectors matcher",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
@@ -25,15 +25,15 @@
|
|
|
25
25
|
"clean": "tsc --build --clean"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@markuplint/ml-spec": "4.0.0-
|
|
29
|
-
"@types/debug": "^4.1.
|
|
28
|
+
"@markuplint/ml-spec": "4.0.0-rc.0",
|
|
29
|
+
"@types/debug": "^4.1.12",
|
|
30
30
|
"debug": "^4.3.4",
|
|
31
|
-
"postcss-selector-parser": "^6.0.
|
|
32
|
-
"type-fest": "^4.
|
|
31
|
+
"postcss-selector-parser": "^6.0.15",
|
|
32
|
+
"type-fest": "^4.10.2"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@types/jsdom": "21.1.
|
|
36
|
-
"jsdom": "
|
|
35
|
+
"@types/jsdom": "21.1.6",
|
|
36
|
+
"jsdom": "24.0.0"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "3fdeb45cb69ed52b3a215a7520cea1181601443f"
|
|
39
39
|
}
|