mirror of
https://github.com/danog/dart-sass.git
synced 2025-01-22 05:41:14 +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 '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);
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user