@@ -251,10 +251,7 @@ function takeRecords(node) {
251251 while ( node . parentNode ) {
252252 node = node . parentNode ;
253253 }
254-
255- // The node is a ShadowRoot, an IE will have a memory leak if you put the observer
256- // directly on the ShadowRoot, so put it on the head so it does not leak
257- var observer = node . head . __observer ;
254+ var observer = node . __observer ;
258255 if ( observer ) {
259256 handler ( node , observer . takeRecords ( ) ) ;
260257 takeMutations ( ) ;
@@ -263,29 +260,19 @@ function takeRecords(node) {
263260
264261var forEach = Array . prototype . forEach . call . bind ( Array . prototype . forEach ) ;
265262
263+
266264// observe a node tree; bail if it's already being observed.
267265function observe ( inRoot ) {
268-
269- if ( inRoot && inRoot . head && inRoot . head . __observer ) {
266+ if ( inRoot . __observer ) {
270267 return ;
271268 }
272269 // For each ShadowRoot, we create a new MutationObserver, so the root can be
273270 // garbage collected once all references to the `inRoot` node are gone.
274271 // Give the handler access to the root so that an 'in document' check can
275272 // be done.
276-
277- // originally the observer was on the ShadowRoot (inRoot) (single observer);
278- // this causes a memory leak within IE. To fix this, we must put a an observer
279- // on both the head and body nodes on the ShadowRoot
280273 var observer = new MutationObserver ( handler . bind ( this , inRoot ) ) ;
281- observer . observe ( inRoot . head , { childList : true , subtree : true } ) ;
282- observer . observe ( inRoot . body , { childList : true , subtree : true } ) ;
283-
284- // this needs to be on head or it will leak in IE
285- // IE does not like it when you have non-standard attributes on root dom's, so put
286- // the observer on the head element
287- // this is used to check if the observer has been attached already (above)
288- inRoot . head . __observer = observer ;
274+ observer . observe ( inRoot , { childList : true , subtree : true } ) ;
275+ inRoot . __observer = observer ;
289276}
290277
291278// upgrade an entire document and observe it for elements changes.
0 commit comments