Skip to content

Commit

Permalink
perf(theme/search): prevent repeated rendering of same page (#2398)
Browse files Browse the repository at this point in the history
  • Loading branch information
zonemeen committed May 27, 2023
1 parent 86a3c24 commit e7be720
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/client/theme-default/components/VPLocalSearchBox.vue
Expand Up @@ -155,6 +155,9 @@ debouncedWatch(
if (canceled) return
const c = new Map<string, Map<string, string>>()
for (const { id, mod } of mods) {
const mapId = id.slice(0, id.indexOf('#'))
let map = c.get(mapId)
if (map) continue
const comp = mod.default ?? mod
if (comp?.render) {
const app = createApp(comp)
Expand All @@ -178,8 +181,6 @@ debouncedWatch(
const sections = div.innerHTML.split(headingRegex)
app.unmount()
sections.shift()
const mapId = id.slice(0, id.indexOf('#'))
let map = c.get(mapId)
if (!map) {
map = new Map()
c.set(mapId, map)
Expand Down

0 comments on commit e7be720

Please sign in to comment.