Skip to content
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

[BUGFIX release] Adds toJSON to list of descriptorTrap assertion exception #16347

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/ember-metal/lib/properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ if (EMBER_METAL_ES5_GETTERS) {
property === 'toString' ||
property === 'valueOf' ||
property === 'inspect' ||
property === 'toJSON' ||
Symbol && property === Symbol.toPrimitive ||
Symbol && property === Symbol.toStringTag
) {
Expand All @@ -148,6 +149,7 @@ if (EMBER_METAL_ES5_GETTERS) {
});

trap.toString = trap.valueOf = () => '[COMPUTED PROPERTY]';
trap.toJSON = trap.valueOf = () => '[COMPUTED PROPERTY]';

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be folded into the previous line

Copy link
Contributor Author

@mani-mishra mani-mishra Mar 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chancancode Sorry. I did't understand the above statement.
Do you mean something like below?

trap.toString = trap.toSJON = trap.valueOf = () => '[COMPUTED PROPERTY]';

I can raise a PR, if needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that’s what Godfrey was suggesting

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raised a PR for this #16365

// Without a proxy, we can only trap the "likely" properties
['isDescriptor', 'setup', 'teardown', 'get', '_getter', 'set', '_setter', 'meta'].forEach(property => {
Expand Down