On Mon, Feb 2, 2015 at 8:45 AM, Danny Dorfman <[email protected]> wrote:
> I am afraid that won't work on regular objects either. This code:
>
> #include <v8.h>
> #include <iostream>
> int main(int argc, char* argv[]) {
>     v8::V8::Initialize();
>     v8::Isolate* isolate = v8::Isolate::New();
>     v8::Isolate::Scope isolate_scope(isolate);
>     v8::HandleScope handle_scope(isolate);
>     v8::Handle<v8::Context> context = v8::Context::New(isolate);
>     v8::Context::Scope context_scope(context);
>     v8::Handle<v8::Object> obj = v8::Object::New(isolate);
>     obj->ForceSet(v8::String::NewFromUtf8(isolate,"field1"),
> v8::String::NewFromUtf8(isolate,"value1"), v8::DontEnum);
>     obj->ForceSet(v8::String::NewFromUtf8(isolate,"field2"),
> v8::String::NewFromUtf8(isolate,"value2"), v8::None);
>     v8::Local<v8::Array> property_names = obj->GetPropertyNames();
>     std::cout << "obj got " << property_names->Length() << " field(s)" <<
> std::endl;
>     v8::Local<v8::Array> own_property_names = obj->GetOwnPropertyNames();
>     std::cout << "obj got " << own_property_names->Length() << " own
> field(s)" << std::endl;
>     return 0;
>
> }
>
>
> Prints:
>
> obj got 1 field(s)
> obj got 1 own field(s)

You're right, I had a quick look at the source and it seems
JSObject::GetEnumElementKeys() unconditionally filters out DONT_ENUM
properties.

You may want to file a bug report in the bug tracker.  There is no
test coverage for this particular edge case and
Object.getOwnPropertyNames() does return the non-enumerable property
so I assume it's a bug.

-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to