Browse Source

Don't count duplicated queries on elements not attached to DOM

Gaël Métais 10 years ago
parent
commit
1e60a43075
1 changed files with 6 additions and 1 deletions
  1. 6 1
      lib/tools/phantomas/custom_modules/modules/domQYLT/domQYLT.js

+ 6 - 1
lib/tools/phantomas/custom_modules/modules/domQYLT/domQYLT.js

@@ -365,7 +365,12 @@ exports.module = function(phantomas) {
         phantomas.log('DOM query: by %s - "%s" (using %s) in %s', type, query, fnName, context);
         phantomas.incrMetric('DOMqueries');
 
-        if (context && context.indexOf('DocumentFragment') === -1) {
+        if (context && (
+                context.indexOf('html') === 0 ||
+                context.indexOf('body') === 0 ||
+                context.indexOf('head') === 0 ||
+                context.indexOf('#document') === 0
+            )) {
             DOMqueries.push(type + ' "' + query + '" with ' + fnName + ' (in context ' + context + ')');
         }
     });