From 84cdd2f4f0d1f23e755d8e8f1610d6e0638cb96c Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Sun, 20 Dec 2015 00:00:01 +0000 Subject: [PATCH] Add Javascript feature detection for `oninput` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adds a feature detection for the `oninput` event, which isn’t supported in older browsers[1]. This means that the code that highlights placeholders will only be run in browsers that support the `oninput` event. 1. http://caniuse.com/#feat=input-event --- app/assets/javascripts/highlightTags.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/assets/javascripts/highlightTags.js b/app/assets/javascripts/highlightTags.js index 2a6d7c34d..472d479c7 100644 --- a/app/assets/javascripts/highlightTags.js +++ b/app/assets/javascripts/highlightTags.js @@ -1,6 +1,10 @@ (function(Modules) { "use strict"; + if ( + !('oninput' in document.createElement('input')) + ) return; + const tagPattern = /\(\([^\)\(]+\)\)/g; Modules.HighlightTags = function() {