1 21 24 package org.lobobrowser.html.domimpl; 25 26 import org.lobobrowser.js.*; 27 import org.w3c.dom.Node ; 28 import org.w3c.dom.html2.HTMLCollection; 29 30 public class ChildHTMLCollection extends AbstractScriptableDelegate implements HTMLCollection { 31 private final NodeImpl rootNode; 32 33 36 public ChildHTMLCollection(NodeImpl node) { 37 super(); 38 rootNode = node; 39 } 40 41 public int getLength() { 42 return this.rootNode.getChildCount(); 43 } 44 45 public Node item(int index) { 46 return this.rootNode.getChildAtIndex(index); 47 } 48 49 public Node namedItem(String name) { 50 org.w3c.dom.Document doc = this.rootNode.getOwnerDocument(); 51 if(doc == null) { 52 return null; 53 } 54 Node node = (Node ) doc.getElementById(name); 56 if(node != null && node.getParentNode() == this.rootNode) { 57 return node; 58 } 59 return null; 60 } 61 62 public int indexOf(Node node) { 63 return this.rootNode.getChildIndex(node); 64 } 65 } 66 | Popular Tags |