-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
#274 Remove [[Enumerate]] and associated reflective capabilities #976
Conversation
@Yongqu can you review? |
|
||
var proxy = new Proxy({x:1}, { | ||
ownKeys: function() { | ||
return ['a','b']; |
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.
add a test case with returning symbol?
we need to cleanup all the comments, and basically implements EnumerateObjectProperties, going through prototype etc. Please also cleanup the comments. hmm we shouldn't go through the prototype here as the forin enumerator will go through the prototype chain. but we need to enumerate only enumerable properties. #Closed Refers to: lib/Runtime/Library/JavascriptProxy.cpp:855 in b74d582. [](commit_id = b74d582, deletion_comment = False) |
}); | ||
|
||
var keys="" | ||
for(var key in proxy){ keys += key;} |
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.
test case with proxy on the prototype
*enumerator = IteratorObjectEnumerator::Create(scriptContext, trapResult); | ||
|
||
JavascriptArray* arrTrapResult = JavascriptArray::FromVar(trapResult); | ||
uint32 len = arrTrapResult->GetLength(); |
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.
check the return is JavascriptArray
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.
checked above: JavascriptOperators::IsArray
do you mean we need to check with JavascriptArray::Is()? #Resolved
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.
hmm interesting. JavascriptOperators::IsArray() is true for proxy over array. you can't cast it to JavascriptArray if the trapResult is a proxy.
In reply to: 63961681 [](ancestors = 63961681)
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.
need a generic method to iterate the array (or array like) elements? do we have such method?
In reply to: 63966947 [](ancestors = 63966947,63961681)
|
||
Var arrayIterator = JavascriptOperators::GetIterator(RecyclableObject::FromVar(trapResult), scriptContext); | ||
*enumerator = IteratorObjectEnumerator::Create(scriptContext, arrayIterator); | ||
|
||
return TRUE; |
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.
instead of iterators, it's easier to use enumerator. You can see the code in JavascriptObject::CreateKeysHelper, in similar pattern.
// 13.7.5.15EnumerateObjectProperties(O)# | ||
// for (let key of Reflect.ownKeys(obj)) { | ||
Var trapResult = JavascriptOperators::GetOwnPropertyNames(this, scriptContext); | ||
Assert(JavascriptArray::Is(trapResult)); |
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.
I would prefer a check in runtime then just Assert, at least a defense in depth.
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
@leirocks any update on this? |
check the property descriptor, only enumerable properties should be shown up
add test case for getPrototypeOf, and non-string values in ownKeys trap returning array
c542fd8
to
48db1aa
Compare
#274 Remove [[Enumerate]] and associated reflective capabilities
Fixes #274