Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

addChild的时候添加校验 #602

Open
hunter2009 opened this issue Jul 15, 2016 · 6 comments
Open

addChild的时候添加校验 #602

hunter2009 opened this issue Jul 15, 2016 · 6 comments

Comments

@hunter2009
Copy link

addChild能不能添加对childName的校验,如果存在同名子control就删除掉之前的,然后再添加新的?

@otakustay
Copy link
Member

这个不大可能,破坏性太强,有同名的抛异常倒可以考虑

@hunter2009
Copy link
Author

目前的做法也是强制替换(容易埋坑),只是之前的还在队列里面,这样children看起来很奇怪...

                if (childName) {
                    control.childName = childName;
                    this.childrenIndex[childName] = control;
                }

@otakustay
Copy link
Member

目前的做法虽然会引起childrenIndex的覆盖,但是不会导致child被销毁,而直接销毁child会引起视图上展现效果的不同,我不大希望引入这么大的变化

所以为了不坑,通过抛异常的方式告知这里出现了问题似乎是个办法

@hunter2009
Copy link
Author

同名的时候,不对control做任何操作(不添加,不替换),直接抛一个异常,类似于这样的处理?

@otakustay
Copy link
Member

是的,直接就不渲染了,这样至少写代码的人能发现错误去改正

hunter2009 [email protected]于2016年7月15日 周五下午3:47写道:

同名的时候,不对control做任何操作(不添加,不替换),直接抛一个异常,类似于这样的处理?


You are receiving this because you commented.

Reply to this email directly, view it on GitHub
#602 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAnCPXKrl4cX-2Rni555FFIHthIa7oCpks5qVzsQgaJpZM4JNFS0
.

@yankun01
Copy link
Contributor

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants