From 9865451a7e97aaef71962687e5a7a7b4a768ee3e Mon Sep 17 00:00:00 2001 From: d98762625 Date: Mon, 11 Feb 2019 16:46:54 +0000 Subject: [PATCH] try/catch to allow chef to run from prod file --- src/web/RecipeWaiter.mjs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/web/RecipeWaiter.mjs b/src/web/RecipeWaiter.mjs index 8559860915..803893531e 100755 --- a/src/web/RecipeWaiter.mjs +++ b/src/web/RecipeWaiter.mjs @@ -8,6 +8,8 @@ import HTMLOperation from "./HTMLOperation"; import Sortable from "sortablejs"; import Utils from "../core/Utils"; +/*eslint no-console: ["off"] */ + /** * Waiter to handle events related to the recipe. @@ -560,14 +562,20 @@ class RecipeWaiter { this.ingredientRuleID = null; this.ingredientChildRuleID = null; + // Find relevant rules in the stylesheet - for (const i in document.styleSheets[0].cssRules) { - if (document.styleSheets[0].cssRules[i].selectorText === ".ingredients") { - this.ingredientRuleID = i; - } - if (document.styleSheets[0].cssRules[i].selectorText === ".ingredients > div") { - this.ingredientChildRuleID = i; + // try/catch for chrome 64+ CORS error on cssRules. + try { + for (const i in document.styleSheets[0].cssRules) { + if (document.styleSheets[0].cssRules[i].selectorText === ".ingredients") { + this.ingredientRuleID = i; + } + if (document.styleSheets[0].cssRules[i].selectorText === ".ingredients > div") { + this.ingredientChildRuleID = i; + } } + } catch (e) { + // Do nothing. } }