Wednesday, 7 January 2015

XPath ordering in FIrefox



How would one make XPath (1) one-liner prioritisation work in Firefox? I get why or acts the way it does, but why does | "fails" in Firefox but "works" in Chrome?


Which one is right (if this behaviour defined in the spec) and how to get it working across the board?



<a>b</a>
<a id="b"></a>


Chrome 39.0.2171.95



> $x("//a[@id='b' or text()='b']")
< [<a>​b​</a>​, <a id=​"b">​</a>​]

> $x("//a[@id='b'] | //a[text()='b']")
< [<a id=​"b">​</a>​, <a>​b​</a>​]


Firefox 34.0.5



> $x("//a[@id='b' or text()='b']")
< Array [ <a>, <a#b> ]

> $x("//a[@id='b'] | //a[text()='b']")
< Array [ <a>, <a#b> ]

No comments:

Post a Comment