1
0
mirror of https://github.com/hakimel/reveal.js.git synced 2025-01-17 13:28:29 +01:00

Merge pull request #3444 from t-fritsch/allow-link-to-nested-element-id

add support for links to the id of an element nested inside slide
This commit is contained in:
Hakim El Hattab 2023-08-06 13:41:23 +02:00 committed by GitHub
commit b66121e32b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 8 deletions

2
dist/reveal.esm.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/reveal.js vendored

File diff suppressed because one or more lines are too long

2
dist/reveal.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -49,7 +49,7 @@ export default class Location {
// If the first bit is not fully numeric and there is a name we // If the first bit is not fully numeric and there is a name we
// can assume that this is a named link // can assume that this is a named link
if( !/^[0-9]*$/.test( bits[0] ) && name.length ) { if( !/^[0-9]*$/.test( bits[0] ) && name.length ) {
let element; let slide;
let f; let f;
@ -62,12 +62,14 @@ export default class Location {
// Ensure the named link is a valid HTML ID attribute // Ensure the named link is a valid HTML ID attribute
try { try {
element = document.getElementById( decodeURIComponent( name ) ); slide = document
.getElementById( decodeURIComponent( name ) )
.closest('.slides>section, .slides>section>section');
} }
catch ( error ) { } catch ( error ) { }
if( element ) { if( slide ) {
return { ...this.Reveal.getIndices( element ), f }; return { ...this.Reveal.getIndices( slide ), f };
} }
} }
else { else {