/* exported domEventListener */
function domEventListener(settings, modules, parts) {
   'use strict';

   var actualSettings = settings.get(),
      rootNode = actualSettings.rootNode,
      attributeName = actualSettings.attribute,
      actualSelector = settings.getSelector(),
      registerStrategy = decideDomMutationStrategy();

   function decideDomMutationStrategy() {
      var strategy = tryToGetMutationObserverStrategy();
      // TODO remove the following line to enable/disable MutationObserver support
      //strategy = null;

      if(strategy === null) {
         return createLegacyDomMutationStrategy();
      }

      return strategy;
   }

   function onElementAdded(addedNode) {
      var addedModules = addedNode.querySelectorAll(actualSelector);

      if(addedNode.hasAttribute(attributeName)) {
         loadModule(addedNode);
      }

      each(addedModules, function(addedModule) {
         loadModule(addedModule);
      });

      modules.provisionFinished();
      parts.provisionFinished();
   }

   function onElementRemoved(removedElement) {
      var addedModuleElements = removedElement.querySelectorAll(actualSelector);

      each(addedModuleElements, function(moduleElement) {
         unloadModules(moduleElement);
      });

      if(removedElement.hasAttribute(attributeName)) {
         unloadModules(removedElement);
      }
   }

   function loadModule(moduleElement) {
      return modules.provisionModule(moduleElement);
   }

   function unloadModules(moduleElement) {
      modules.unloadModules(moduleElement);
   }

   return {
      registerToEvents : registerStrategy.register,
      unregisterToEvents : registerStrategy.unregister
   };

   function tryToGetMutationObserverStrategy() {

      var ObserverCreator = window.MutationObserver || window.WebKitMutationObserver || null,
         observerConfig = { attributes: true, childList: true, characterData: true, subtree: true },
         observer;

      if(ObserverCreator !== null) {
         observer = new ObserverCreator(onMutation);

         return {
            register : registerToEvents,
            unregister : unregisterToEvents
         };
      }
      else {
         return null;
      }

      function registerToEvents() {
         observer.observe(rootNode, observerConfig);
      }

      function unregisterToEvents() {
         observer.takeRecords();
         observer.disconnect();
      }

      function onMutation(mutations, observer) {

         each(mutations, function(mutationRecord) {

            each(mutationRecord.addedNodes, function(addedNode) {
               onElementAdded(addedNode);
            });

            each(mutationRecord.removedNodes, function(removedNode) {
               onElementRemoved(removedNode);
            });
         });

         observer.takeRecords();
      }
   }

   function createLegacyDomMutationStrategy() {

      var DOM_NODE_INSERTED_EVENT_NAME = 'DOMNodeInserted',
         DOM_NODE_REMOVED_EVENT_NAME = 'DOMNodeRemoved';

      function registerToEvents() {
         rootNode.addEventListener(DOM_NODE_INSERTED_EVENT_NAME, onDomNodeInserted, false);
         rootNode.addEventListener(DOM_NODE_REMOVED_EVENT_NAME, onDomNodeRemoved, false);
      }

      function onDomNodeInserted(event) {
         onElementAdded(event.target);
      }

      function unregisterToEvents() {
         rootNode.removeEventListener(DOM_NODE_INSERTED_EVENT_NAME, onDomNodeInserted);
         rootNode.removeEventListener(DOM_NODE_REMOVED_EVENT_NAME, onDomNodeRemoved, false);
      }

      function onDomNodeRemoved(event) {
         onElementRemoved(event.target);
      }

      return {
         register : registerToEvents,
         unregister : unregisterToEvents
      };
   }
}

@@ -385,113 +385,152 @@
 var 
-strategy = tryToGetMutationObserverStrategy();%0A      // TODO remove the following line to enable/disable 
+WebKitMutationObserver = window.WebKitMutationObserver,%0A         MutationObserver = window.MutationObserver,%0A         strategy;%0A%0A      if(WebKit
 Muta
@@ -545,25 +545,21 @@
 rver
- support%0A
+) %7B%0A 
       
-//
+  
 stra
@@ -569,42 +569,198 @@
 y = 
-null;%0A%0A      if(strategy === null)
+tryToGetMutationObserverStrategy(WebKitMutationObserver);%0A      %7D%0A      else if(MutationObserver) %7B%0A         strategy = tryToGetMutationObserverStrategy(MutationObserver);%0A      %7D%0A      else
  %7B%0A 
@@ -767,22 +767,26 @@
         
-return
+strategy =
  createL
@@ -1933,115 +1933,37 @@
 egy(
-) %7B%0A%0A      var ObserverCreator = window.MutationObserver %7C%7C window.WebKitMutationObserver %7C%7C null,
+ObserverCreator) %7B%0A
 %0A      
-  
+var
  obs
@@ -2072,267 +2072,43 @@
 rver
-;%0A%0A      if(ObserverCreator !== null) %7B%0A         observer = new ObserverCreator(onMutation);%0A%0A         return %7B%0A            register : registerToEvents,%0A            unregister : unregisterToEvents%0A         %7D;%0A      %7D%0A      else %7B%0A         return null;%0A      %7D
+ = new ObserverCreator(onMutation);
 %0A%0A  
@@ -2721,32 +2721,136 @@
 cords();%0A      %7D
+%0A%0A      return %7B%0A         register : registerToEvents,%0A         unregister : unregisterToEvents%0A      %7D;
 %0A   %7D%0A%0A   functi

clean up code