Polymer/CustomElements — pull request #131 by jmesserly (2014-09-23 21:19:25+00:00)
Title: create a unique observer for each tree so detached nodes can be GC'd

[MutationObserver.observe](https://dom.spec.whatwg.org/#dom-mutationobserver-observe) keeps its target alive. Since the global observer has the ShadowRoot as its target, it kept the ShadowRoot alive. This meant all custom elements with shadow roots were living forever in polyfilled mode.

The issue is easy to fix except for one catch: `CustomElement.takeRecords()`. The API previously had global knowledge--it could take records for everything everywhere. The simplest thing I could think of is to have it optionally accept a node, which allows us to do something like `CustomElements.takeRecords(this.shadowRoot);`

As far as I can tell, most tests aren't affected because they only wanted to trigger takeRecords on document. The only test I found that is affected is: https://github.com/Polymer/polymer-dev/blob/master/test/js/paths.js#L21 ... and adding the "work" parameter fixes it. What's the best way to coordinate that across repos?