소스 검색

add support for links to the id of an element nested inside slide

fixes hakimel/reveal.js#3231
Thomas Fritsch 1 년 전
부모
커밋
27ff199627
1개의 변경된 파일6개의 추가작업 그리고 4개의 파일을 삭제
  1. 6 4
      js/controllers/location.js

+ 6 - 4
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
 		// 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 ) {
-				return { ...this.Reveal.getIndices( element ), f };
+			if( slide ) {
+				return { ...this.Reveal.getIndices( slide ), f };
 			}
 			}
 		}
 		}
 		else {
 		else {