[annotator-dev] highlight ranges gets broken on load

Ewald Zietsman 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?

Ewald Zietsman

Technical Coor**dinator*
Website: www.siyavula.com
The Open Innovation Studio, 27 Buitenkant Street, Cape Town, 8001

A Shuttleworth Foundation Seeded Project
Website: www.shuttleworthfoundation.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/annotator-dev/attachments/20110908/b2843915/attachment-0002.html>

More information about the annotator-dev mailing list