Implement live HTMLCollection cache for Document.links

Closes #1885.