-
Notifications
You must be signed in to change notification settings - Fork 5
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
Feature/define accessor #14
Conversation
@@ -240,6 +240,14 @@ | |||
|
|||
var e2 = new EooClass2('prop1', 'prop2'); | |||
e2.test(); | |||
|
|||
Class.defineAccessor(Sub.prototype, 'testProp'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里我感觉不应该给prototype
,直接给个类就行了?毕竟我们的语义是“给类添加一个访问器”
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在业务中应该是:defineAccessor(exports, name),主要考虑到defineAccessor不局限于 function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
懂了~
|
||
function simpleGetter(name) { | ||
var body = 'return typeof this.' + MEMBERS + ' === \'object\' ? this.' | ||
+ MEMBERS + '.' + name + ' : undefined;'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
防着name
是关键字,乖乖[""]
吧……别的没啥了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
for ISSUE #9