From f8be0659abdb5552d62968d36fe4b73e5f2bc455 Mon Sep 17 00:00:00 2001 From: YuyingWu Date: Thu, 13 Nov 2014 12:25:14 +0800 Subject: [PATCH 1/2] optimize function back MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bug:no judgement for whether back’s parentNode or back exists, might cause js error “Cannot read property 'removeChild' of null” --- flippant.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flippant.js b/flippant.js index 31f8c8b..72ec2d8 100644 --- a/flippant.js +++ b/flippant.js @@ -52,7 +52,7 @@ function flip(flipper, content, type, class_name, timeout) { flipper.classList.remove('flipped') window.setTimeout(function () { back.classList.remove(class_name) - document.body.removeChild(back) + back.parentNode && back.parentNode.removeChild(back) }, timeout) } From 716ed0da58930599c7eb9d55100fe4da7ff68cc4 Mon Sep 17 00:00:00 2001 From: YuyingWu Date: Sat, 22 Nov 2014 15:42:50 +0800 Subject: [PATCH 2/2] fix the problem: timeout in params doesn't work old version, time in setTimeout was fixed, so timeout in params does not work at all. --- flippant.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flippant.js b/flippant.js index 72ec2d8..73796b3 100644 --- a/flippant.js +++ b/flippant.js @@ -34,13 +34,13 @@ function flip(flipper, content, type, class_name, timeout) { } else { window.setTimeout(function () { style_func(back) - }, 0) + }, timeout) } window.setTimeout(function () { back.classList.add('flipper') back.classList.add('flipped') flipper.classList.add('flipped') - }, 0) + }, timeout) back.addEventListener('close', close) back.close = close