XmlFollowingIterator constructor

XmlFollowingIterator(
  1. XmlNode start
)

Implementation

XmlFollowingIterator(XmlNode start) {
  final following = <XmlNode>[];
  for (var parent = start.parent, child = start;
      parent != null;
      parent = parent.parent, child = child.parent!) {
    if (child is XmlAttribute) {
      final attributesIndex = parent.attributes.indexOf(child);
      following.addAll(parent.attributes.sublist(attributesIndex + 1));
      following.addAll(parent.children);
    } else {
      final childrenIndex = parent.children.indexOf(child);
      following.addAll(parent.children.sublist(childrenIndex + 1));
    }
  }
  _todo.addAll(following.reversed);
}