From 27ff1996277e343fb8c6a57cb3f804f29b13a8fa Mon Sep 17 00:00:00 2001 From: Thomas Fritsch Date: Sat, 5 Aug 2023 16:24:22 +0200 Subject: [PATCH] add support for links to the id of an element nested inside slide fixes hakimel/reveal.js#3231 --- js/controllers/location.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/js/controllers/location.js b/js/controllers/location.js index 6fa48292..645aa353 100644 --- a/js/controllers/location.js +++ b/js/controllers/location.js @@ -49,7 +49,7 @@ export default class Location { // If the first bit is not fully numeric and there is a name we // can assume that this is a named link if( !/^[0-9]*$/.test( bits[0] ) && name.length ) { - let element; + let slide; let f; @@ -62,12 +62,14 @@ export default class Location { // Ensure the named link is a valid HTML ID attribute try { - element = document.getElementById( decodeURIComponent( name ) ); + slide = document + .getElementById( decodeURIComponent( name ) ) + .closest('.slides>section, .slides>section>section'); } catch ( error ) { } - if( element ) { - return { ...this.Reveal.getIndices( element ), f }; + if( slide ) { + return { ...this.Reveal.getIndices( slide ), f }; } } else {