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

.extend 创建类中的 parent 问题 #56

Closed
mescoda opened this issue Mar 30, 2015 · 2 comments
Closed

.extend 创建类中的 parent 问题 #56

mescoda opened this issue Mar 30, 2015 · 2 comments

Comments

@mescoda
Copy link
Contributor

mescoda commented Mar 30, 2015

.extend 创建的多层子类中,使用 .parent(name) 调用父类中方法时,会因为 this 一直是新建出来的实例,造成死循环的问题。

解决方法:

  1. Prototype 中的重写方法,被 John Resig 借鉴过
  2. 最早可能是 mootools 中的利用 augments.callee.caller
@jinzhubaofu
Copy link
Contributor

目前我们只支持一层extend

feature/ng分支上,是支持多层extend的,源码是在这里

另外,在这个分支上,.parent(name)方法的实现也做了简化,并更新为.$parent(...)。实现方案是你提到的2

@mescoda
Copy link
Contributor Author

mescoda commented Mar 30, 2015

了解了
多谢

@mescoda mescoda closed this as completed Mar 30, 2015
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

2 participants