From 65f82a180100b0c9942221c3b768294d0a46436a Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Tue, 20 Sep 2016 13:09:02 +0100 Subject: [PATCH] Add feature detection test for classList --- public/assets/enhancements.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/public/assets/enhancements.js b/public/assets/enhancements.js index 0fa2bc8..6f2e1b1 100644 --- a/public/assets/enhancements.js +++ b/public/assets/enhancements.js @@ -33,11 +33,12 @@ && div.firstChild.namespaceURI ) == 'http://www.w3.org/2000/svg'; })(), - querySelector: typeof document.querySelector === 'function' + querySelector: typeof document.querySelector === 'function', + classList: 'classList' in document.createElement('div') }; // Check required features for favourite nodes - if(supports.localStorage && supports.inlineSVG && supports.querySelector) { + if(supports.localStorage && supports.inlineSVG && supports.querySelector && supports.classList) { // Get heart SVG var xhr = new XMLHttpRequest(); @@ -91,14 +92,16 @@ } // Add ios class to body on iOS devices - DOMReady(function() { - if( - /iPad|iPhone|iPod/.test(navigator.userAgent) - && !window.MSStream - && document.body.classList - ) { - document.body.classList.add('ios'); - } - }); + if(supports.classList) { + DOMReady(function() { + if( + /iPad|iPhone|iPod/.test(navigator.userAgent) + && !window.MSStream + && document.body.classList + ) { + document.body.classList.add('ios'); + } + }); + } })();