Skip to content

Commit

Permalink
fix(lifecycle): continue to handle data
Browse files Browse the repository at this point in the history
  • Loading branch information
QingWei-Li committed May 31, 2017
1 parent d9b487e commit 955d3d5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/core/init/lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,22 @@ export function initLifecycle (vm) {
}

export function callHook (vm, hook, data, next = noop) {
let newData = data
const queue = vm._hooks[hook]

const step = function (index) {
const hook = queue[index]
if (index >= queue.length) {
next(newData)
next(data)
} else {
if (typeof hook === 'function') {
if (hook.length === 2) {
hook(data, result => {
newData = result
data = result
step(index + 1)
})
} else {
const result = hook(data)
newData = result !== undefined ? result : newData
data = result !== undefined ? result : data
step(index + 1)
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/front-matter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ const install = function (hook, vm) {
})
}

window.$docsify.plugins = [].concat(install, window.$docsify.plugins)
$docsify.plugins = [].concat(install, $docsify.plugins)

0 comments on commit 955d3d5

Please sign in to comment.