From 6d05b647b351753dd8db3efe68c2d5e41529c8d7 Mon Sep 17 00:00:00 2001 From: maqiuyan Date: Tue, 24 Nov 2015 10:15:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96fastclick=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/fastclick.js | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/js/fastclick.js b/js/fastclick.js index 4bc9a0f1..140eecf8 100644 --- a/js/fastclick.js +++ b/js/fastclick.js @@ -218,6 +218,14 @@ */ var deviceIsBlackBerry10 = navigator.userAgent.indexOf('BB10') > 0; + /** + * 判断是否组合型label + * 夏苒添加 + * + * @type {Boolean} + */ + var isCompositeLabel = false; + /** * Determine whether a given element requires a native click. * @@ -238,7 +246,10 @@ // 夏苒添加start,如果label上有needsclick这个类,则用原生的点击,否则,用模拟点击 var parent = target; while(parent && (parent.tagName.toUpperCase() !== "BODY")) { - if(parent.tagName.toUpperCase() === "LABEL" && (/\bneedsclick\b/).test(parent.className)) return true; + if (parent.tagName.toUpperCase() === "LABEL") { + isCompositeLabel = true; + if ((/\bneedsclick\b/).test(parent.className)) return true; + } parent = parent.parentNode; } // 夏苒添加end @@ -660,25 +671,6 @@ return true; } - /** - * 夏苒添加 start - * - */ - var isCompositeLabel = false; // 是否组合型label - var parent = this.targetElement; - - // 判断父元素中是否有 label,如果有则为组合型label - while(parent && (parent.tagName.toUpperCase() !== "BODY")) { - if(parent.tagName.toUpperCase() === "LABEL") { - isCompositeLabel = true; - } - parent = parent.parentNode; - } - /** - * 夏苒添加 end - */ - - // Derive and check the target element to see whether the mouse event needs to be permitted; // unless explicitly enabled, prevent non-touch click events from triggering actions, // to prevent ghost/doubleclicks.