Bug 645416, part 25 - Add support for enumerating symbol-keyed properties. r=Waldo.
Object.keys, Object.getOwnPropertyNames, and for-in loops skip symbol-keyed properties per spec, but Object.defineProperties sees them, and a future Reflect.ownKeys API will need to be able to see them. This patch changes the comments on JSITER_FOREACH and JSITER_KEYVALUE, but not the behavior. The comments were just wrong.
This commit is contained in:
@@ -239,6 +239,9 @@ BaseProxyHandler::keys(JSContext *cx, HandleObject proxy, AutoIdVector &props)
|
||||
for (size_t j = 0, len = props.length(); j < len; j++) {
|
||||
JS_ASSERT(i <= j);
|
||||
id = props[j];
|
||||
if (JSID_IS_SYMBOL(id))
|
||||
continue;
|
||||
|
||||
AutoWaivePolicy policy(cx, proxy, id, BaseProxyHandler::GET);
|
||||
if (!getOwnPropertyDescriptor(cx, proxy, id, &desc))
|
||||
return false;
|
||||
@@ -419,7 +422,7 @@ DirectProxyHandler::getOwnPropertyNames(JSContext *cx, HandleObject proxy,
|
||||
{
|
||||
assertEnteredPolicy(cx, proxy, JSID_VOID, ENUMERATE);
|
||||
RootedObject target(cx, proxy->as<ProxyObject>().target());
|
||||
return GetPropertyNames(cx, target, JSITER_OWNONLY | JSITER_HIDDEN, &props);
|
||||
return GetPropertyNames(cx, target, JSITER_OWNONLY | JSITER_HIDDEN | JSITER_SYMBOLS, &props);
|
||||
}
|
||||
|
||||
bool
|
||||
@@ -1068,7 +1071,8 @@ class ScriptedDirectProxyHandler : public DirectProxyHandler {
|
||||
MutableHandle<PropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||
virtual bool defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
|
||||
MutableHandle<PropertyDescriptor> desc) MOZ_OVERRIDE;
|
||||
virtual bool getOwnPropertyNames(JSContext *cx, HandleObject proxy, AutoIdVector &props);
|
||||
virtual bool getOwnPropertyNames(JSContext *cx, HandleObject proxy, AutoIdVector &props)
|
||||
MOZ_OVERRIDE;
|
||||
virtual bool delete_(JSContext *cx, HandleObject proxy, HandleId id, bool *bp) MOZ_OVERRIDE;
|
||||
virtual bool enumerate(JSContext *cx, HandleObject proxy, AutoIdVector &props) MOZ_OVERRIDE;
|
||||
|
||||
@@ -1679,7 +1683,8 @@ ScriptedDirectProxyHandler::getOwnPropertyNames(JSContext *cx, HandleObject prox
|
||||
|
||||
// Here we add a bunch of extra sanity checks. It is unclear if they will also appear in
|
||||
// the spec. See step 10-11
|
||||
return ArrayToIdVector(cx, proxy, target, trapResult, props, JSITER_OWNONLY | JSITER_HIDDEN,
|
||||
return ArrayToIdVector(cx, proxy, target, trapResult, props,
|
||||
JSITER_OWNONLY | JSITER_HIDDEN | JSITER_SYMBOLS,
|
||||
cx->names().getOwnPropertyNames);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user