|
[HtmlUnit] CVS Commit: ElementArray.java: removed workaround for Jaxen bug: msg#00017java.htmlunit.devel
Log Message: ----------- removed workaround for Jaxen bug 55 which is fixed since some monthes Modified Files: -------------- htmlunit/src/java/com/gargoylesoftware/htmlunit/javascript: ElementArray.java (http://cvs.sourceforge.net/viewcvs.py/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/javascript/ElementArray.java) Revision Data ------------- Index: ElementArray.java =================================================================== RCS file: /cvsroot/htmlunit/htmlunit/src/java/com/gargoylesoftware/htmlunit/javascript/ElementArray.java,v retrieving revision 1.19 retrieving revision 1.20 diff -Lsrc/java/com/gargoylesoftware/htmlunit/javascript/ElementArray.java -Lsrc/java/com/gargoylesoftware/htmlunit/javascript/ElementArray.java -u -d -r1.19 -r1.20 --- src/java/com/gargoylesoftware/htmlunit/javascript/ElementArray.java +++ src/java/com/gargoylesoftware/htmlunit/javascript/ElementArray.java @@ -37,7 +37,6 @@ */ package com.gargoylesoftware.htmlunit.javascript; -import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -55,7 +54,6 @@ import com.gargoylesoftware.htmlunit.WebWindow; import com.gargoylesoftware.htmlunit.html.DomNode; import com.gargoylesoftware.htmlunit.html.HtmlElement; -import com.gargoylesoftware.htmlunit.html.Util; /** * An array of elements. Used for the element arrays returned by <tt>document.all</tt>, @@ -76,7 +74,7 @@ */ public static final String JS_OBJECT_NAME = "ElementArray"; private static final long serialVersionUID = 4049916048017011764L; - + private XPath xpath_; private DomNode node_; /** @@ -89,7 +87,7 @@ * Create an instance. Javascript objects must have a default constructor. */ public ElementArray() { - + // nothing } /** @@ -100,7 +98,6 @@ */ public void init(final DomNode node, final XPath xpath) { init(node, xpath, NOPTransformer.INSTANCE); - } /** @@ -172,10 +169,10 @@ */ public final Object get( final int index, final Scriptable start ) { final ElementArray array = (ElementArray) start; - final List elements = array.getElementsSorted(); - + final List elements = array.getElements(); + if( index >= 0 && index < elements.size()) { - return getScriptableFor(elements.get(index)); + return getScriptableFor(transformer_.transform(elements.get(index))); } else { return NOT_FOUND; @@ -183,43 +180,13 @@ } /** - * Due to bug in Jaxen: http://jira.codehaus.org/browse/JAXEN-55 - * the nodes returned by the xpath evaluation are not correctly sorted. - * We have therefore to sort them. - * @return the sorted list. - */ - private List getElementsSorted() { - final List nodes = getElements(); - final List sortedNodes; - if (nodes.size() > 1) { - sortedNodes = new ArrayList(); - for (final Iterator iter = Util.getFollowingAxisIterator(node_); iter.hasNext();) { - final Object node = iter.next(); - if (nodes.contains(node)) { - sortedNodes.add(node); - nodes.remove(node); - if (nodes.isEmpty()) { - break; // nothing to sort anymore - } - } - } - } - else { - sortedNodes = nodes; // already "sorted" - } - - CollectionUtils.transform(sortedNodes, transformer_); - return sortedNodes; - } - - /** * Gets the html elements. Avoid calling it multiple times within a method because the evaluation * needs to be performed each time again * @return the list of {@link HtmlElement} contained in this collection */ private List getElements() { try { - final List list = xpath_.selectNodes(node_); + final List list = xpath_.selectNodes(node_); return list; } catch (final JaxenException e) { @@ -241,8 +208,8 @@ if( result != NOT_FOUND ) { return result; } - - final ElementArray currentArray = ((ElementArray) start); + + final ElementArray currentArray = ((ElementArray) start); final List elements = currentArray.getElements(); CollectionUtils.transform(elements, transformer_); @@ -288,21 +255,21 @@ catch (final SAXPathException e) { throw Context.reportRuntimeError("Failed getting sub elements by name" + e.getMessage()); } - + // Test to see if we are trying to get the length of this array? If so, pass the processing up // to the higher level processing if ("length".equals(name)) { return NOT_FOUND; } - + final List subElements = array.getElements(); if (subElements.size() > 1) { - getLog().debug("Property \"" + name + "\" evaluated (by name) to " + array + " with " + getLog().debug("Property \"" + name + "\" evaluated (by name) to " + array + " with " + subElements.size() + " elements"); return array; } else if (subElements.size() == 1) { - final SimpleScriptable singleResult = getScriptableFor(subElements.get(0)); + final SimpleScriptable singleResult = getScriptableFor(subElements.get(0)); getLog().debug("Property \"" + name + "\" evaluated (by name) to " + singleResult); return singleResult; } @@ -363,7 +330,7 @@ return array; } - + /** * Just for debug purpose. * {@inheritDoc} @@ -374,7 +341,7 @@ } return super.toString(); } - + /** * Called for the js "==". * {@inheritDoc} @@ -385,8 +352,8 @@ } else if (other instanceof ElementArray) { final ElementArray otherArray = (ElementArray) other; - if (node_ == otherArray.node_ - && xpath_.toString().equals(otherArray.xpath_.toString()) + if (node_ == otherArray.node_ + && xpath_.toString().equals(otherArray.xpath_.toString()) && transformer_.equals(otherArray.transformer_)) { return Boolean.TRUE; } @@ -394,7 +361,7 @@ return NOT_FOUND; } } - + return super.equivalentValues(other); } } ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: [HtmlUnit] CVS Commit: /htmlunit: fixed dependencies description page, Marc Guillemot |
|---|---|
| Next by Date: | [HtmlUnit] CVS Commit: gargoylesoftware/htmlunit: include reference to html page, mguillem |
| Previous by Thread: | [HtmlUnit] CVS Commit: maven.xml: spellcheck fix, mguillem |
| Next by Thread: | [HtmlUnit] CVS Commit: gargoylesoftware/htmlunit: include reference to html page, mguillem |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |