Urara-Blog/node_modules/.pnpm-store/v3/files/28/cfdab28e730a1356ce4fbb580a33c7e68588f69c498b5b4eef8d4d06a818795e45d677b13f740b4b831b9a42a7ea3a4849f90399e9e7ffe3240c00f3da8b61
2022-08-14 01:14:53 +08:00

29 lines
722 B
Text

module.exports = {
itMatchesOne(arr, term) {
return arr.some((i) => term.search(i) >= 0);
},
parseAttrSelector(node) {
const { content } = node;
const regex = /(^class|^id)([*^?~|$=]*)+(?:("\s*)([^"\\]*?(?:\\.[^"\\]*)*?)(\s*")|('\s*)([^'\\]*?(?:\\.[^'\\]*)*?)(\s*'))/i;
const [type, operator, head, classes, foot] = content
.split(regex)
.filter((part) => part);
return {
type,
operator,
head,
classes: classes ? classes.split(' ').map((c) => c.replace(/"|'/g, '')) : [],
foot,
};
},
attrStringify({
type, operator, head, classes, foot,
}) {
return `${type}${operator || ''}${head || ''}${classes.join(' ')}${foot || ''}`;
},
};