[annotator-dev] highlight ranges gets broken on load
ewald at siyavula.com
Thu Sep 8 13:46:23 UTC 2011
I've hacked and broken the annotator code now adding a categories plugin
(and support for different highlight colours for different annotations).
I've run into a problem that I can't seem to figure out although I have some
idea what might be the problem.
My version of the annotator is here: git at github.com:
When I create annotations they appear on the page as expected. They even
have the correct colours I have specified. When I inspect their 'ranges'
attribute its looks ok. However, when I make two of them overlap the whole
thing breaks on page load and I get the error: "Uncaught TypeError: Cannot
read property 'nodeType' of undefined"
After quite a search I have found out that the last annotation added that
overlaps with another annotation causes this error and that the 'range'
attribute that gets loaded has its 'startOffset' or 'endOffset' set for the
amount relative to the annotation it overlaps with, instead of relative to
the original DOM. The crash happens because the annotation it overlaps with
is not in the DOM yet and therefore the element that defines its highlight
range is not defined yet. Can anyone point me in a direction to get around
this? I'm thinking highlights should always be defined relative to the
original DOM before any highlights were put in? Maybe loading them in
reverse order could make this go away?
The Open Innovation Studio, 27 Buitenkant Street, Cape Town, 8001
A Shuttleworth Foundation Seeded Project
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the annotator-dev