-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
defaults() sets/buries values on __proto__ #75
Comments
of course the isDefault property is correctly set by the defaults() and accessible on but it is not easily inspectable, and I expect ObjectModel to set the default properties explicitly on the "instance". Is the current behavior by design? desirable for some reason? |
Hi there, Putting defaults in the prototype is the intended behaviour. I just explained this today in this other issue : #74 (comment) I explained it this way in the library docs (if it's not clear, I'll reword this section):
Now you're right that I could show them in the custom formatter. I didn't do it in the first place because there are lots of other stuff in the prototype that seem useless to display, like The same question applies on undeclared properties, i.e. existing properties that are not part of the model definition. Should we show them or not ? |
Hi again, I think it would be great if undeclared props on unfrozen instances would be inspectable, and also if the defaults [Prototype] props could be shown (and maybe even flagged in the inspector as defaults) thanks again for your engagement! |
There are several reasons why the prototype is a great place to put default values:
I'll see what I can do to improve the current formatter and have a [Prototype] and [Undeclared] section |
rock on. great answers! |
In general, i like it a lot. Actually the expandable |
another option could be: |
Ah, just remembered (while you're into the custom formatting): If I have a SetModel inside of a Model prop, it is not expandable in the custom formatter... would be nice. (should i rather open a separate issue for this one?) |
prototype has to be expandable, first because it is another object and it would be incorrect to put these props on the same level, and secondly because some models have too much bloat in it. Let me open another issue to discuss on the formatter: #76 |
When I create a class that extends ObjectModel, with a required property (with a default set), and then create an instance, the default value is not added to the target, but rather buried down in the
__proto__
(thus does not show up in the Chrome inspector Custom Formatter):shows:
i expect:
The text was updated successfully, but these errors were encountered: