joseph / Monocle

A silky, tactile browser-based ebook JavaScript library.
http://monocle.inventivelabs.com.au
MIT License
743 stars 200 forks source link

Xpath locus search not working in IE #228

Open lmvco opened 10 years ago

lmvco commented 10 years ago

Hi,

The locus search tests available in Monocle - http://test.monoclejs.com/test/locus-search/index.html - that use xpath does not work in IE10.

It throws the error below: "SCRIPT438: Object doesn't support property or method 'evaluate' "

It seems to be caused by lack of xpath support in IE.

My suggestion is to use a library that implement xpath quering like xpathjs - https://github.com/andrejpavlovic/xpathjs

Is it possible?

joseph commented 10 years ago

Sounds like a good idea, but you can do this in your application, right? I'd rather not introduce a dependency in Monocle...

aronwoost commented 10 years ago

Just want to add that xpathjs is awesome. Have worked with it on earlier Androids. Just make sure you check this issue when working with xhtml content.

lmvco commented 10 years ago

Hi Joseph,

I cannot do it on my application because I am using Monocle moveTo function passing a Xpath as argumentm (error throw in inside monocore.js) - pageForXPath function.

I understand your concerns regarding externals library dependencies. However, since Internet Explorer is increasing popularity - with Surface and other Windows 8 tablets - I suggest to create this dependency until Microsoft add a full support to xpath in Internet Explorer.

Anyway, I found another xpath library from Google that is very interesting also:

Wicked Good XPath is a Google-authored pure JavaScript implementation of the DOM Level 3 XPath specification. It enables XPath evaluation for HTML documents in every browser. We believe it to be the fastest XPath implementation available in JavaScript.

https://code.google.com/p/wicked-good-xpath/

joseph commented 10 years ago

Hm, I'm confused — according to the XPathJS doc, XPathJS.bindDomLevel3XPath(); will shim in document.evaluate. So it should be transparent?

To be honest, given the state of XPath support in various browsers (including the zombie Androids), I've been thinking of ditching it from the locus object altogether — CSS selectors are arguably easier and certainly better supported.