mirror of
https://github.com/danog/dart-sass.git
synced 2025-01-22 13:51:31 +01:00
Avoid depending on iterator.current != null
. (#877)
With the NNBD change to Dart, it's no longer safe to rely on an iterator returning `null` when it has hit the end (or before calling `moveNext` the first time). For non-nullable element types, it will have to throw instead. This PR rewrites code that currently rely on a `null` value to recognize the end of an iterator.
This commit is contained in:
parent
e110961120
commit
31c09606b9
@ -522,14 +522,17 @@ List<List<T>> paths<T>(Iterable<List<T>> choices) => choices.fold(
|
||||
QueueList<List<ComplexSelectorComponent>> _groupSelectors(
|
||||
Iterable<ComplexSelectorComponent> complex) {
|
||||
var groups = QueueList<List<ComplexSelectorComponent>>();
|
||||
var iterator = complex.iterator..moveNext();
|
||||
while (iterator.current != null) {
|
||||
var group = <ComplexSelectorComponent>[];
|
||||
do {
|
||||
var iterator = complex.iterator;
|
||||
if (!iterator.moveNext()) return groups;
|
||||
var group = <ComplexSelectorComponent>[iterator.current];
|
||||
groups.add(group);
|
||||
while (iterator.moveNext()) {
|
||||
if (group.last is Combinator || iterator.current is Combinator) {
|
||||
group.add(iterator.current);
|
||||
} while (iterator.moveNext() &&
|
||||
(iterator.current is Combinator || group.last is Combinator));
|
||||
groups.add(group);
|
||||
} else {
|
||||
group = [iterator.current];
|
||||
groups.add(group);
|
||||
}
|
||||
}
|
||||
return groups;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user