Browse Source

fixed Node.nodes()

Nicolas Cannasse 19 years ago
parent
commit
2ee617170c
2 changed files with 22 additions and 12 deletions
  1. 11 6
      std/flash/Boot.hx
  2. 11 6
      std/neko/NekoNode__.hx

+ 11 - 6
std/flash/Boot.hx

@@ -170,18 +170,23 @@ class Boot {
 					p : 0,
 					a : childNodes,
 					next : function() {
-						return this.a[this.p++];
-					},
-					hasNext : function() {
 						while true {
 							var x = this.a[this.p];
 							if( x == null )
-								return false;
-							if( x.nodeType == 1 )
-								return true;
+								return null;
 							this.p++;
+							if( x.nodeType == 1 )
+								return x;
 						}
 						return null;
+					},
+					hasNext : function() {
+						var x = this.next();
+						if( x != null ) {
+							this.p--;
+							return true;
+						}
+						return false;
 					}
 				};
 			};

+ 11 - 6
std/neko/NekoNode__.hx

@@ -105,18 +105,23 @@ class NekoNode__ implements Node {
 			p : 0,
 			a : childNodes,
 			next : function() {
-				return this.a[this.p++];
-			},
-			hasNext : function() {
 				while true {
 					var x = this.a[this.p];
 					if( x == null )
-						return false;
-					if( x.nodeType == element_node )
-						return true;
+						return null;
 					this.p++;
+					if( x.nodeType == 1 )
+						return x;
 				}
 				return null;
+			},
+			hasNext : function() {
+				var x = this.next();
+				if( x != null ) {
+					this.p--;
+					return true;
+				}
+				return false;
 			}
 		};
 	}