I am trying to write HTML annotation service. So I want to attach an annotation to HTML elements where a user clicked. So far this post helped me find HTML element. However I want to locate the element back in DOM tree.
So if I traverse DOM tree down until I met the element, will be my traverse path uniquely identify the element, so I can restore annotation each time, or browsers can build DOM tree differently and there is a risk of changing browser can bring me in trouble?
Another option can be look for position of found element innerHTML in BODY.innerHTML. However if I have repeatable elements I can't provide exact mapping. Any other suggestions? Please do not advise to add some unique id for every HTML element and then use it. It will bloat HTML and I want to avoid it.