New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IE8: 'XPathResult' is undefined #5
Comments
Note that even with that shim, I'm still receiving a few related errors:
|
For the first one,
but IE8 shows:
If I change the first value of
So that initial offset seems to be problematic due to how whitespace is handled. It looks like Chrome is returning 32 total nodes for the text whereas IE8 reports just 21 - the difference is Chrome has a bunch of nodes containing just newlines. Filtering those out yields 18 nodes. This also means that the result is expecting a series of newlines that IE8 just doesn't have. |
If we level the playing field by ignoring newline-only nodes, the first test passes. This ends up looking something like:
And of course, the value to test for becomes |
Test range 25 still has issues, of course (it's only matching So, the TLDR here is, IE8 (and several other browsers) produce rather inconsistent results when you're reading the contents of DOM nodes that have newlines in/between them - some include this extra whitespace, others don't. As a result, it's kind of hard to test predictably. I don't know that stripping whitespace in the test helper is necessarily the best way to handle this, but at least it's consistent. We will need to alert users of the inconsistency of course. |
So here's a super small patch that gives appropriate expected values for IE (so far) based on how it handles whitespace in the DOM, that leaves the rest of our testing intact. This goes right after the original
|
@nickstenning @tilgovi what do you think? |
On further reflection, I suspect this fix won't really help us. I'm not too familiar with how we're storing the data yet, but I assume that if browsers are representing this data differently, then annotations won't attach properly across browsers? |
It depends on which version of Annotator are we talking about. With H's fork, and and further work based on that, or based on newer Annotator versions which have that work merged, we have several alternative ways to solve that, including character position-based matching, and text matching, including some level of error tolerance. So if this fails, it's not a total tragedy - but that won't help current upstream Annotator. |
I suspect there's probably a way to solve this with standard upstream annotator, but I'm not familiar enough with the current situation to propose a good solution. The current problem here is that whitepsace between nodes are not reported by all browsers - as @tilgovi said elsewhere, perhaps we should just not store those. |
My code further up the thread is an attempt at precisely that, fwiw. |
Are we still talking about the XPath expressions here? What do they have to do with whitespaces? (Sorry, I can't follow - probably because I did not analyze your code changes closely enough.) |
Yes - we are making certain assumptions about where in the text things appear, and how far along they are at. If you calculate that with whitespace vs not-whitespace, the results are necessarily different. Assuming that Annotator is working in a similar fashion for how it's storing this data, this will be effected in the same way, I think? I guess the bigger issue here is that to resolve this as I've described probably requires breaking all existing annotations (that span across nodes). 😦 But again, I'm not super-familiar with how things are being stored, so I may be misinterpreting how big of an issue this is. |
I believe as-is, the end result will be that annotations will still show up, just in the wrong places (in IE8 and maybe 9)? |
Anecdotally, this seems to be working without issue on my ad hoc testing. But I might just have not found the thing what breaks the other thing yet. |
What's the action here? I don't think we need to change the |
I've documented any issues that affect Annotator - even if the reason is an upstream issue. I'd say this is still relevant to xpath-range since we're actually getting and storing that data and have the opportunity to perform any normalization we want on it. But either way, these tests are failing in most versions of IE, so something needs to be done (here) for this to be considered passing. |
As of 3046fc5 we shouldn't have a strict dependency on XPath being available for our simple expressions. |
IE8 is now passing all the tests here with rangy and wgxpath. |
Going back to openannotation/annotator#173, there's no support for XPath related operations in any version of IE really, so we'll need a shim here.
Wicked-Good-Xpath
does in fact solve most of the issues here, so I recommend adding that as part of the main package, since it affects even modern IEs.The text was updated successfully, but these errors were encountered: