From 5a13dda054f08e7780eb1a3bd76212b5ce75176f Mon Sep 17 00:00:00 2001 From: Yoonchae Lee Date: Sat, 16 Nov 2024 15:55:27 +0900 Subject: [PATCH] optional chaining syntax `?.` is replaced as it's only supported on chrome 80+, and older Anki versions use older chromium Fixes #126 --- src/addon/web/global_card.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/addon/web/global_card.js b/src/addon/web/global_card.js index 1624eb8..c0a203e 100644 --- a/src/addon/web/global_card.js +++ b/src/addon/web/global_card.js @@ -109,7 +109,9 @@ } const qEl = document.getElementById('qa') - qEl?.setAttribute('data-efdrc-editing', 'true') + if (qEl !== null) { + qEl.setAttribute('data-efdrc-editing', 'true') + } const fld = target.getAttribute('data-EFDRCfield') window.pycmd('EFDRC!focuson#' + fld) @@ -125,7 +127,9 @@ } const qEl = document.getElementById('qa') - qEl?.removeAttribute('data-efdrc-editing') + if (qEl !== null) { + qEl.removeAttribute('data-efdrc-editing') + } const el = target if (EFDRC.CONF.remove_span) { @@ -284,7 +288,9 @@ // which is reset when card or side changes. // It can be used for styling in note type templates const qEl = document.getElementById('qa') - qEl?.setAttribute('data-efdrc-ctrl', 'true') + if (qEl !== null) { + qEl.setAttribute('data-efdrc-ctrl', 'true') + } const els = document.querySelectorAll('[data-EFDRCfield]') for (const el of els) { @@ -298,7 +304,9 @@ EFDRC.ctrlup = function () { if (EFDRC.CONF.ctrl_click) { const qEl = document.getElementById('qa') - qEl?.removeAttribute('data-efdrc-ctrl') + if (qEl !== null) { + qEl.removeAttribute('data-efdrc-ctrl') + } const els = document.querySelectorAll('[data-EFDRCfield]') for (const el of els) {