public static List nodeChildren()

in gwt-util/src/main/java/jetbrains/jetpad/mapper/gwt/DomUtil.java [46:90]


  public static List<Node> nodeChildren(final Node n) {
    return new AbstractList<Node>() {
      @Override
      public Node get(int index) {
        return n.getChild(index);
      }

      @Override
      public Node set(int index, Node element) {
        if (element.getParentElement() != null) {
          throw new IllegalStateException();
        }

        Node child = get(index);
        n.replaceChild(child, element);
        return child;
      }

      @Override
      public void add(int index, Node element) {
        if (element.getParentElement() != null) {
          throw new IllegalStateException();
        }

        if (index == 0) {
          n.insertFirst(element);
        } else {
          Node prev = n.getChild(index - 1);
          n.insertAfter(element, prev);
        }
      }

      @Override
      public Node remove(int index) {
        Node child = n.getChild(index);
        n.removeChild(child);
        return child;
      }

      @Override
      public int size() {
        return n.getChildCount();
      }
    };
  }