Use unvendor() in Pseudo.

Also, fix unvendor().
This commit is contained in:
Natalie Weizenbaum 2016-08-19 14:25:44 -07:00
parent 02a9780b43
commit 977bb9c3d2
2 changed files with 7 additions and 7 deletions

View File

@ -4,11 +4,10 @@
import 'dart:math' as math; import 'dart:math' as math;
import '../../utils.dart';
import '../../visitor/interface/selector.dart'; import '../../visitor/interface/selector.dart';
import '../selector.dart'; import '../selector.dart';
final _vendorPrefix = new RegExp(r'^-[a-zA-Z0-9]+-');
class PseudoSelector extends SimpleSelector { class PseudoSelector extends SimpleSelector {
final String name; final String name;
@ -34,7 +33,7 @@ class PseudoSelector extends SimpleSelector {
PseudoSelector(String name, this.type, {this.argument, this.selector}) PseudoSelector(String name, this.type, {this.argument, this.selector})
: name = name, : name = name,
normalizedName = name.replaceFirst(_vendorPrefix, ''); normalizedName = unvendor(name);
PseudoSelector withSelector(SelectorList selector) => PseudoSelector withSelector(SelectorList selector) =>
new PseudoSelector(name, type, argument: argument, selector: selector); new PseudoSelector(name, type, argument: argument, selector: selector);

View File

@ -48,11 +48,12 @@ FileSpan spanForList(List<AstNode> nodes) {
} }
String unvendor(String name) { String unvendor(String name) {
assert(!name.isEmpty); if (name.length < 2) return name;
if (name.codeUnitAt(0) == $dash) return name; if (name.codeUnitAt(0) != $dash) return name;
if (name.codeUnitAt(1) == $dash) return name;
for (var i = 1; i < name.length; i++) { for (var i = 2; i < name.length; i++) {
if (name.codeUnitAt(0) == $dash) return name.substring(i + 1); if (name.codeUnitAt(i) == $dash) return name.substring(i + 1);
} }
return name; return name;
} }