Skip to content

Commit

Permalink
fix(plugin-vue): custom block prev handling
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Dec 31, 2020
1 parent 0ea0a4a commit dd80760
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions packages/plugin-vue/src/handleHotUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,24 +103,25 @@ export async function handleHotUpdate(

// custom blocks update causes a reload
// because the custom block contents is changed and it may be used in JS.
for (let i = 0; i < nextCustoms.length; i++) {
const prev = prevCustoms[i]
const next = nextCustoms[i]
if (!prev || !isEqualBlock(prev, next)) {
const mod = modules.find((m) =>
m.url.includes(`type=${prev.type}&index=${i}`)
)
if (mod) {
affectedModules.add(mod)
} else {
affectedModules.add(mainModule)
if (prevCustoms.length !== nextCustoms.length) {
// block rmeoved/added, force reload
affectedModules.add(mainModule)
} else {
for (let i = 0; i < nextCustoms.length; i++) {
const prev = prevCustoms[i]
const next = nextCustoms[i]
if (!prev || !isEqualBlock(prev, next)) {
const mod = modules.find((m) =>
m.url.includes(`type=${prev.type}&index=${i}`)
)
if (mod) {
affectedModules.add(mod)
} else {
affectedModules.add(mainModule)
}
}
}
}
if (prevCustoms.length > nextCustoms.length) {
// block rmeoved, force reload
affectedModules.add(mainModule)
}

let updateType = []
if (needRerender) {
Expand Down

0 comments on commit dd80760

Please sign in to comment.