From 11bfae6e0785178cdd0ddc407f56aed22b3f50f4 Mon Sep 17 00:00:00 2001 From: Kang Cheng Date: Tue, 6 Nov 2018 21:19:41 +0000 Subject: [PATCH 1/2] fix: IE10 compatibility --- src/core/render/compiler.js | 2 +- src/plugins/search/search.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/render/compiler.js b/src/core/render/compiler.js index 34c64ae72..e1cd9bf4c 100644 --- a/src/core/render/compiler.js +++ b/src/core/render/compiler.js @@ -241,7 +241,7 @@ export class Compiler { } href = router.toURL(href, null, router.getCurrentPath()) } else { - attrs += href.startsWith('mailto:') ? '' : ` target="${linkTarget}"` + attrs += href.indexOf('mailto:') === 0 ? '' : ` target="${linkTarget}"` } if (config.target) { diff --git a/src/plugins/search/search.js b/src/plugins/search/search.js index 7a14ebbce..1bae81368 100644 --- a/src/plugins/search/search.js +++ b/src/plugins/search/search.js @@ -16,7 +16,9 @@ function escapeHtml(string) { function getAllPaths(router) { const paths = [] - document.querySelectorAll('.sidebar-nav a:not(.section-link):not([data-nosearch])').forEach(node => { + const nodes = document.querySelectorAll('.sidebar-nav a:not(.section-link):not([data-nosearch])') + for (var i = 0; i < nodes.length; i += 1) { + const node = nodes[i] const href = node.href const originHref = node.getAttribute('href') const path = router.parse(href).path @@ -28,7 +30,7 @@ function getAllPaths(router) { ) { paths.push(path) } - }) + } return paths } From b55cf4e602f9e9fc73752e1aa96d50771fdf304b Mon Sep 17 00:00:00 2001 From: Kang Cheng Date: Wed, 7 Nov 2018 19:47:23 +0000 Subject: [PATCH 2/2] chore: use built-in helper fn --- src/plugins/search/search.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/plugins/search/search.js b/src/plugins/search/search.js index 1bae81368..1f246ed36 100644 --- a/src/plugins/search/search.js +++ b/src/plugins/search/search.js @@ -16,9 +16,7 @@ function escapeHtml(string) { function getAllPaths(router) { const paths = [] - const nodes = document.querySelectorAll('.sidebar-nav a:not(.section-link):not([data-nosearch])') - for (var i = 0; i < nodes.length; i += 1) { - const node = nodes[i] + Docsify.dom.findAll('.sidebar-nav a:not(.section-link):not([data-nosearch])').forEach(node => { const href = node.href const originHref = node.getAttribute('href') const path = router.parse(href).path @@ -30,7 +28,7 @@ function getAllPaths(router) { ) { paths.push(path) } - } + }) return paths }