diff --git a/src/core/fetch/index.js b/src/core/fetch/index.js index 581725076..1853a0297 100644 --- a/src/core/fetch/index.js +++ b/src/core/fetch/index.js @@ -73,7 +73,7 @@ export function fetchMixin(proto) { case 'object': key = Object.keys(notFoundPage) .sort((a, b) => b.length - a.length) - .find(key => path.match(new RegExp('^' + key))); + .find(k => path.match(new RegExp('^' + k))); path404 = (key && notFoundPage[key]) || defaultPath; break; diff --git a/src/core/init/lifecycle.js b/src/core/init/lifecycle.js index d8106adc9..d695ed6e6 100644 --- a/src/core/init/lifecycle.js +++ b/src/core/init/lifecycle.js @@ -18,21 +18,22 @@ export function initLifecycle(vm) { }); } -export function callHook(vm, hook, data, next = noop) { - const queue = vm._hooks[hook]; +export function callHook(vm, hookName, data, next = noop) { + const queue = vm._hooks[hookName]; const step = function(index) { - const hook = queue[index]; + const hookFn = queue[index]; + if (index >= queue.length) { next(data); - } else if (typeof hook === 'function') { - if (hook.length === 2) { - hook(data, result => { + } else if (typeof hookFn === 'function') { + if (hookFn.length === 2) { + hookFn(data, result => { data = result; step(index + 1); }); } else { - const result = hook(data); + const result = hookFn(data); data = result === undefined ? data : result; step(index + 1); } diff --git a/src/core/render/embed.js b/src/core/render/embed.js index 63db66972..5159754ab 100644 --- a/src/core/render/embed.js +++ b/src/core/render/embed.js @@ -14,6 +14,7 @@ function walkFetchEmbed({ embedTokens, compile, fetch }, cb) { } while ((token = embedTokens[step++])) { + // eslint-disable-next-line no-shadow const next = (function(token) { return text => { let embedToken; diff --git a/src/core/render/index.js b/src/core/render/index.js index 068f66cd6..42e62ba96 100644 --- a/src/core/render/index.js +++ b/src/core/render/index.js @@ -190,7 +190,9 @@ export function renderMixin(proto) { html = formatUpdated(html, opt.updatedAt, this.config.formatUpdated); } - callHook(this, 'afterEach', html, text => renderMain.call(this, text)); + callHook(this, 'afterEach', html, hookData => + renderMain.call(this, hookData) + ); }; if (this.isHTML) {