瀏覽代碼

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
Hakim El Hattab 1 年之前
父節點
當前提交
b66121e32b
共有 5 個文件被更改,包括 6 次插入4 次删除
  1. 0 0
      dist/reveal.esm.js
  2. 0 0
      dist/reveal.esm.js.map
  3. 0 0
      dist/reveal.js
  4. 0 0
      dist/reveal.js.map
  5. 6 4
      js/controllers/location.js

文件差異過大導致無法顯示
+ 0 - 0
dist/reveal.esm.js


文件差異過大導致無法顯示
+ 0 - 0
dist/reveal.esm.js.map


文件差異過大導致無法顯示
+ 0 - 0
dist/reveal.js


文件差異過大導致無法顯示
+ 0 - 0
dist/reveal.js.map


+ 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
 		// 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 {

部分文件因文件數量過多而無法顯示