Add PseudoSelector.normalizedName.

This commit is contained in:
Natalie Weizenbaum 2016-08-12 15:42:21 -07:00
parent 2b120f005d
commit b5b4cd5a8b
2 changed files with 8 additions and 2 deletions

View File

@ -8,9 +8,13 @@ import 'package:charcode/charcode.dart';
import '../selector.dart';
final _vendorPrefix = new Regex(r'^-[a-zA-Z0-9]+-');
class PseudoSelector extends SimpleSelector {
final String name;
final String normalizedName;
final PseudoType type;
final String argument;
@ -29,7 +33,9 @@ class PseudoSelector extends SimpleSelector {
}
int _maxSpecificity;
PseudoSelector(this.name, this.type, {this.argument, this.selector});
PseudoSelector(String name, this.type, {this.argument, this.selector})
: name = name,
normalizedName = name.replaceFirst(_vendorPrefix, '');
List<SimpleSelector> unify(List<SimpleSelector> compound) {
if (compound.contains(this)) return compound;

View File

@ -187,7 +187,7 @@ bool _simpleIsSuperselectorOfCompound(SimpleSelector simple,
// Some selector pseudoclasses can match normal selectors.
if (theirSimple is PseudoSelector && theirSimple.selector != null &&
_subselectorPseudos.contains(theirSimple.name)) {
_subselectorPseudos.contains(theirSimple.normalizedName)) {
return theirSimple.selector.components.any((complex) {
if (complex.components.length != 1) return false;
var compound = complex.components.single as CompoundSelector;