mirror of
https://github.com/danog/dart-sass.git
synced 2025-01-21 21:31:11 +01:00
Use unvendor() in Pseudo.
Also, fix unvendor().
This commit is contained in:
parent
02a9780b43
commit
977bb9c3d2
@ -4,11 +4,10 @@
|
||||
|
||||
import 'dart:math' as math;
|
||||
|
||||
import '../../utils.dart';
|
||||
import '../../visitor/interface/selector.dart';
|
||||
import '../selector.dart';
|
||||
|
||||
final _vendorPrefix = new RegExp(r'^-[a-zA-Z0-9]+-');
|
||||
|
||||
class PseudoSelector extends SimpleSelector {
|
||||
final String name;
|
||||
|
||||
@ -34,7 +33,7 @@ class PseudoSelector extends SimpleSelector {
|
||||
|
||||
PseudoSelector(String name, this.type, {this.argument, this.selector})
|
||||
: name = name,
|
||||
normalizedName = name.replaceFirst(_vendorPrefix, '');
|
||||
normalizedName = unvendor(name);
|
||||
|
||||
PseudoSelector withSelector(SelectorList selector) =>
|
||||
new PseudoSelector(name, type, argument: argument, selector: selector);
|
||||
|
@ -48,11 +48,12 @@ FileSpan spanForList(List<AstNode> nodes) {
|
||||
}
|
||||
|
||||
String unvendor(String name) {
|
||||
assert(!name.isEmpty);
|
||||
if (name.codeUnitAt(0) == $dash) return name;
|
||||
if (name.length < 2) return name;
|
||||
if (name.codeUnitAt(0) != $dash) return name;
|
||||
if (name.codeUnitAt(1) == $dash) return name;
|
||||
|
||||
for (var i = 1; i < name.length; i++) {
|
||||
if (name.codeUnitAt(0) == $dash) return name.substring(i + 1);
|
||||
for (var i = 2; i < name.length; i++) {
|
||||
if (name.codeUnitAt(i) == $dash) return name.substring(i + 1);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user