Memoize query selector functions for big performance gains

This has a notable affect on accessors like ```a.href``` and ```document.links```
which normally walk the whole DOM tree with every access.  The memoization caches
the result of queries like ```Node.getElementsByTagName``` and
```Node.querySelectorAll```, and the cache is cleared whenever a lower segment
of the tree is modified.