Skip to content

Commit

Permalink
fix(viewer): filter the linkable picture tags
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Apr 2, 2022
1 parent f0dd673 commit 69144ef
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions assets/viewer/js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Gallery {
run() {
const self = this;
document.querySelectorAll('img').forEach(function (img) {
if (img.parentElement.tagName !== 'A' && self.validate(img)) {
if (self.validate(img)) {
img.addEventListener('click', function () {
self.gallery.show();
});
Expand All @@ -30,7 +30,13 @@ class Gallery {
}

validate(img) {
return !img.hasAttribute('data-viewer-invisible');
if (img.parentElement.tagName === 'A' || img.hasAttribute('data-viewer-invisible')) {
return false;
}
if (img.parentElement.tagName === 'PICTURE') {
return this.validate(img.parentElement);
}
return true;
}
}

Expand Down

0 comments on commit 69144ef

Please sign in to comment.