(cssPseudoClass: string, dataType: CSSWhatDataType)
| 394 | protected selectorListType?: PseudoClassSelectorList; |
| 395 | |
| 396 | constructor(cssPseudoClass: string, dataType: CSSWhatDataType) { |
| 397 | super(cssPseudoClass); |
| 398 | |
| 399 | const selectors: Array<SimpleSelector | SimpleSelectorSequence | ComplexSelector> = []; |
| 400 | const needsHighestSpecificity: boolean = this.specificity === Specificity.SelectorListHighest; |
| 401 | |
| 402 | let specificity: number = 0; |
| 403 | |
| 404 | if (Array.isArray(dataType)) { |
| 405 | for (const asts of dataType) { |
| 406 | const selector: SimpleSelector | SimpleSelectorSequence | ComplexSelector = createSelectorFromAst(asts); |
| 407 | |
| 408 | if (selector instanceof InvalidSelector) { |
| 409 | // Only forgiving selector list can ignore invalid selectors |
| 410 | if (this.selectorListType !== PseudoClassSelectorList.Forgiving) { |
| 411 | selectors.splice(0); |
| 412 | specificity = 0; |
| 413 | break; |
| 414 | } |
| 415 | |
| 416 | continue; |
| 417 | } |
| 418 | |
| 419 | // The specificity of some pseudo-classes is replaced by the specificity of the most specific selector in its comma-separated argument of selectors |
| 420 | if (needsHighestSpecificity && selector.specificity > specificity) { |
| 421 | specificity = selector.specificity; |
| 422 | } |
| 423 | |
| 424 | selectors.push(selector); |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | this.selectors = selectors; |
| 429 | this.specificity = specificity; |
| 430 | // Functional pseudo-classes become dynamic based on selectors in selector list |
| 431 | this.dynamic = this.selectors.some((sel) => sel.dynamic); |
| 432 | } |
| 433 | public toString(): string { |
| 434 | return `:${this.cssPseudoClass}(${this.selectors.join(', ')})${wrap(this.combinator)}`; |
| 435 | } |
nothing calls this directly
no test coverage detected