The Elements class from DOM4 is defined as follows:

class Elements extends Array {
  Element? query(DOMString relativeSelectors);
  Elements queryAll(DOMString relativeSelectors);
};

It should be an extension of the "local" Array class, i.e. the Haxe basic Array class. I found two ways of implementing this. The first one is achieved using an abstract class and forwarding all unknown methods to the underlying Array:

@:forward()
abstract Elements(Array<Element>) {

  public inline function new() {
    this = [];
  }

  public function query(relativeSelectors: DOMString): Element
  { ... }

  public function queryAll(relativeSelectors: DOMString): Elements
  { ... }

  @:arrayAccess public inline function __get(key:UInt) return this[key];
}

Elements is here defined as an abstract class for an Array<Element>. The @:forward() rule says all methods not defined in the abstract class are forwarded to the Array. The last line adds an array accessor to the class (only the getter, not the setter) to allow foo[index] notations.

After discussion on IRC in #haxe, there is another way, simpler, but it comes at a cost. It is possible to use a Haxe static extension:

class Elements {
  static public function query(t: Array<Element>,relativeSelectors: DOMString): Element
  { ... }
  static public function queryAll(t: Array<Element>,relativeSelectors: DOMString): Elements
  { ... }
}

and use it through a

using path.to.Elements;

but then you can't use var foo:Elements = [];, you have to write var foo:Array<Element> = [];
. I am then keeping the solution of the abstract class, that fits better.