Skip to content

Commit

Permalink
Merge pull request hakimel#3444 from t-fritsch/allow-link-to-nested-e…
Browse files Browse the repository at this point in the history
…lement-id

add support for links to the id of an element nested inside slide
  • Loading branch information
hakimel authored Aug 6, 2023
2 parents bddf798 + 3d1eabb commit b66121e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion dist/reveal.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/reveal.esm.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/reveal.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/reveal.js.map

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions js/controllers/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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 {
Expand Down

0 comments on commit b66121e

Please sign in to comment.