JqIterator.hx 465 B

123456789101112131415161718192021
  1. package js.jquery;
  2. class JqIterator {
  3. var j:JQuery;
  4. var i:Int;
  5. inline public function new(j:JQuery):Void {
  6. this.i = 0;
  7. this.j = j;
  8. }
  9. inline public function hasNext():Bool {
  10. return i < j.length;
  11. }
  12. inline public function next():js.html.Element {
  13. return this.j[i++];
  14. }
  15. static function __init__() {
  16. if (untyped __typeof__(JQuery) != "undefined" && JQuery.fn != null)
  17. JQuery.fn.iterator = function() return new JqIterator(js.Lib.nativeThis);
  18. }
  19. }