mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 22:25:12 +00:00
Reformated/commented for clarity
This commit is contained in:
parent
6dce24cc53
commit
ce342d528a
@ -42,29 +42,32 @@ if (typeof storeData !== 'function') {
|
||||
continue
|
||||
}
|
||||
|
||||
//if file is user/index.js
|
||||
//it should save as user
|
||||
var isIndex = (name === 'index')
|
||||
//if file is foo/index.js
|
||||
//it should save as foo
|
||||
let isIndex = (name === 'index')
|
||||
if (isIndex)
|
||||
namePath.pop()
|
||||
|
||||
let module = getModuleNamespace(storeData, namePath)
|
||||
let module = getModuleNamespace(storeData, namePath)
|
||||
let fileModule = getModule(filename)
|
||||
name = namePath.pop()
|
||||
module[name] = module[name] || {}
|
||||
var fileModule = getModule(filename)
|
||||
|
||||
//if file is foo.js, existing properties take priority
|
||||
//because it's the least specific case
|
||||
if (!isIndex) {
|
||||
module[name] = Object.assign({}, fileModule, module[name])
|
||||
module[name].namespaced = true
|
||||
continue
|
||||
}
|
||||
|
||||
//if file is foo/index.js we want to overwrite properties from foo.js
|
||||
//but not from appended mods like foo/actions.js
|
||||
var appendedMods = []
|
||||
if (module[name].appends) {
|
||||
fileModule.appends = module[name].appends
|
||||
for (let append of module[name].appends) {
|
||||
for (let append of module[name].appends)
|
||||
appendedMods[append] = module[name][append]
|
||||
}
|
||||
}
|
||||
module[name] = Object.assign(module[name], fileModule, appendedMods)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user