The renderer marks lightbox-enabled gallery anchors with the with-lb
class (anchors whose href is the image itself) and disabled viewers
with data-viewer="false" on the .gallery-box. This module attaches
a delegated click listener that opens a <dialog>-based lightbox:
shows the clicked anchor's image with its alt text as a caption
previous / next buttons and arrow keys navigate within the same
gallery box, wrapping at the ends
Esc (native dialog cancel), the close button, or a backdrop click
close the dialog; focus returns to the anchor that opened it
Environments without HTMLDialogElement.showModal get no listeners at
all — clicks fall through to normal link navigation.
A small stylesheet is injected once per document and reference-counted
across initGallery() instances; consumers can override the
wdpr-lightbox* classes.
The destroy() cleanup removes the listeners, the dialog element, and
(at refcount zero) the injected stylesheet.
Runtime module for
[[gallery]]lightbox behavior.The renderer marks lightbox-enabled gallery anchors with the
with-lbclass (anchors whose href is the image itself) and disabled viewers withdata-viewer="false"on the.gallery-box. This module attaches a delegated click listener that opens a<dialog>-based lightbox:Environments without
HTMLDialogElement.showModalget no listeners at all — clicks fall through to normal link navigation.A small stylesheet is injected once per document and reference-counted across
initGallery()instances; consumers can override thewdpr-lightbox*classes.The
destroy()cleanup removes the listeners, the dialog element, and (at refcount zero) the injected stylesheet.