Skip to content

Commit

Permalink
optional chaining syntax ?. is replaced
Browse files Browse the repository at this point in the history
as it's only supported on chrome 80+,
and older Anki versions use older chromium
Fixes #126
  • Loading branch information
BlueGreenMagick committed Nov 16, 2024
1 parent e5e3abd commit 5a13dda
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/addon/web/global_card.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down

0 comments on commit 5a13dda

Please sign in to comment.