insertAt method

DOMNode insertAt(
  1. Object? indexSelector,
  2. Object? entry
)

Inserts entry at index of child node that matches indexSelector.

Implementation

DOMNode insertAt(Object? indexSelector, Object? entry) {
  var idx = indexOf(indexSelector);

  if (idx >= 0) {
    var node = _parseNode(entry);
    if (idx >= length) {
      _addToContent(node);
    } else {
      _insertToContent(idx, node);
    }
  } else if (indexSelector is num && isEmptyContent) {
    var node = _parseNode(entry);
    _addImpl(node);
  }

  normalizeContent();

  return this;
}