Skip to content

Commit

Permalink
F 修复render函数递归调用时函数参数隐式赋值的问题/U 优化递归过程,删除非容器组件的items解析
Browse files Browse the repository at this point in the history
  • Loading branch information
NaibinJi committed Jun 18, 2020
1 parent a663a24 commit fcb28a7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/wecomponents.esm.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@weadmin/wecomponents",
"version": "2.0.26",
"version": "2.0.27",
"description": "An implementation of Common Component Language Specs for vue.js",
"main": "lib/wecomponents.esm.js",
"scripts": {
Expand Down
15 changes: 8 additions & 7 deletions src/main.vue
Expand Up @@ -102,26 +102,27 @@ export default {
* @param {*} parentAttributes
*/
function getContainerVnode(config = {}, parentAttributes) {
let _config = _.cloneDeep(config);
let _config = _.cloneDeep(config),
_parentAttributes = _.cloneDeep(parentAttributes);
if (
typeof parentAttributes === 'object' &&
Object.keys(parentAttributes).length > 0 &&
checkIsContainer(parentAttributes.component)
typeof _parentAttributes === 'object' &&
Object.keys(_parentAttributes).length > 0 &&
checkIsContainer(_parentAttributes.component)
) {
_config._parentContainerAttributes = parentAttributes;
_config._parentContainerAttributes = _parentAttributes;
}
return h(
Item,
getRenderData(_config),
// 子组件会保留一份父组件的属性配置,这里可以做限制,仅传递部分需要的数据
config.items
(config.items && checkIsContainer(config.component))
? config.items.map(item =>
getContainerVnode(
item,
Object.assign(parentAttributes || {}, config.attributes, { component: config.component })
Object.assign(_parentAttributes || {}, config.attributes, { component: config.component })
)
)
: []
Expand Down

0 comments on commit fcb28a7

Please sign in to comment.