Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function selectAll(selector: string, elm: MockElement) {
const selectors = parse(selector);
const foundElms: MockElement[] = [];
selectAllRecursion(selectors, elm, foundElms);
return foundElms;
}
export function matches(selector: string, elm: MockElement) {
const selectors = parse(selector);
return matchesSelectors(selectors, elm) !== null;
}
export function selectOne(selector: string, elm: MockElement) {
const selectors = parse(selector);
return selectOneRecursion(selectors, elm);
}
function compileUnsafe(selector, options, context) {
var token = parse(selector, options);
return compileToken(token, options, context);
}
output.logs.push({
reason: 'W:选择器`' + selector + '`不支持',
line: rule.position.start.line,
column: rule.position.start.column
})
return false
}
if (~selector.indexOf(':before') || ~selector.indexOf(':after') || ~selector.indexOf(':last-child') || ~selector.indexOf(':first-child')) {
output.logs.push({
reason: 'W:选择器`' + selector + '`不支持',
line: rule.position.start.line,
column: rule.position.start.column
})
return false
}
selector = cssWhat.parse(selector)[0].map(subselect => {
if (subselect.type === 'descendant') {
return ' '
} else if (subselect.type === 'attribute') {
if (subselect.name === 'class') {
return '.' + subselect.value
} else if (subselect.name === 'id') {
return '#' + subselect.value
}
}
return ''
}).join('')
return selector
}