-
Notifications
You must be signed in to change notification settings - Fork 8
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
Component instances should implement getOwnKeys #326
Comments
what's the use-case for getOwnKeys exactly? |
To get all of the keys of an object, even non-enumerable ones. |
So that's what this is doing, right :) |
Yeah, technically it is, but we do this same sort of override with other types (like DefineMap and DefineList) so that they don't return all of these keys that are added to instances by |
const m = new DefineMap();
Reflect.getOwnKeys(m); // [] I guess DefineList actually doesn't do this: const l = new DefineList();
Reflect.getOwnKeys(l); // ["__inSetup", "_define", "_data", "constructor", "_length"] for lists, devtools is only showing enumerable keys (for this same reason). |
Ok, cool. I think we should update the ownKeys documentation to say that then (that objects can/should filter the list of returned values to be what you probably care about). My concern was that perhaps there was some usage of ownKeys that did expect all of the properties. |
For now I'm going to fix the root cause (canjs/can-define#421), but I'll leave this open in case we decide it's worth doing at some point. |
Right now if you create a component and call
canReflect.getOwnKeys
, you get a bunch of keys back:... these aren't really useful.
Also, this causes CanJS Devtools to throw an exception because it tries to do something basically like this:
The text was updated successfully, but these errors were encountered: