If you know the full path of the element, is going to that path actually hard enough to justify this sort of thing? Usually it's things like collecting elements by common aspects unrelated to their absolute path that's a hassle. And with engines like Sizzle out there, I'm not sure I'm seeing the use-case for this. :-)
I also wonder how you would handle it when moving elements around. Re-assign their hashes, presumably, which starts getting ugly fast.
Note that your approach doesn't only work with elements created at runtime by Javascript; you can assign them after the fact easily enough with a recursive descent function:
function createIDs(element) {
var child;
if (!element.id) {
element.id = createElementID(element);
}
for (child = element.firstChild; child; child = child.nextSibling) {
if (child.nodeType == 1) { // Element
createIDs(child);
}
}
}
// Kick things off
createIDs(document.body);
That's a one-time hit on pre-generated content, rather than always having to re-generate content. Not advocating, just pointing out.