浏览代码

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

Gaël Métais 10 年之前
父节点
当前提交
1e60a43075
共有 1 个文件被更改,包括 6 次插入1 次删除
  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 + ')');
         }
     });