Skip to content

Commit a0d2a1b

Browse files
committed
register_lightbox gets the lightbox element only when it's activated
It looks like `register_lightbox` happens before `NumbasExamElement.init`, which sets `this.lightbox`. A way round this is to only get `this.lightbox` in the function that activates the lightbox, since that's where it's used.
1 parent bb2a2cd commit a0d2a1b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

themes/default/files/scripts/display-base.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,6 @@ class NumbasExamElement extends HTMLElement {
465465
*/
466466
register_lightbox(element) {
467467
const register_image = (img) => {
468-
const {lightbox} = this;
469468

470469
var wrapper = document.createElement('span');
471470
wrapper.setAttribute('class', 'lightbox-image-wrapper');
@@ -492,6 +491,7 @@ class NumbasExamElement extends HTMLElement {
492491
button.title = button.ariaLabel = R('lightbox.zoom in on image');
493492

494493
const activate = () => {
494+
const {lightbox} = this;
495495
lightbox.innerHTML = '';
496496
var elem = img.cloneNode();
497497
const scope = display_util.find_jme_scope(img);

0 commit comments

Comments
 (0)