Implement vtables for DOM nodes.

In addition, this adds extremely basic click event default action support, cleans up the named element registration code, and creates the basis for allowing elements to perform actions when attaching to or detaching from a document tree. Fixes #1527. Works towards #1528, but that shouldn't be closed until we actually fulfil the rules of the spec for implementing default actions.

(Originally by @jdm in #1688.)