From a5fb6e26db21648ab1f274e9482c50ac086b2864 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Tue, 19 Mar 2013 09:50:43 -0700 Subject: [PATCH] Where would we be without my favorite flavor of logic? --- 4chan-X.user.js | 6 +----- lib/polyfill.coffee | 12 ++++++------ 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/4chan-X.user.js b/4chan-X.user.js index be5d93ffa..faac376ed 100644 --- a/4chan-X.user.js +++ b/4chan-X.user.js @@ -1112,11 +1112,7 @@ if ('visibilityState' in document) { return; } - if ('webkitVisibilityState' in document) { - prefix = 'webkit'; - } else if ('mozVisibilityState' in document) { - prefix = 'moz'; - } else { + if (!(prefix = ('webkitVisibilityState' in document ? 'webkit' : 'mozVisibilityState' in document ? 'moz' : void 0))) { return; } property = prefix + 'VisibilityState'; diff --git a/lib/polyfill.coffee b/lib/polyfill.coffee index 0c098b212..5a5b48e10 100644 --- a/lib/polyfill.coffee +++ b/lib/polyfill.coffee @@ -4,12 +4,12 @@ Polyfill = visibility: -> # page visibility API return if 'visibilityState' of document - if 'webkitVisibilityState' of document - prefix = 'webkit' - else if 'mozVisibilityState' of document - prefix = 'moz' - else - return + return unless prefix = ( + if 'webkitVisibilityState' of document + 'webkit' + else if 'mozVisibilityState' of document + 'moz' + ) property = prefix + 'VisibilityState' event = prefix + 'visibilitychange'