Fix handling anchors with nested elements

If an anchor contains nested elements (e.g. a span), onAnchorClick did
not handle the events that start on the nested elements.