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

avoid boolean coercion in property_set #15690

Merged
merged 1 commit into from
Jun 11, 2018
Merged

Conversation

bekzod
Copy link
Contributor

@bekzod bekzod commented Oct 2, 2017

let newRoot = getPath(root, newPath);

if (newRoot) {
if (newRoot !== null && newRoot !== undefined) {
Copy link
Member

Choose a reason for hiding this comment

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

Should this check for typeof newRoot === “function” || (typeof newRoot === ‘object’ && newRoot !== null)?

I don’t think we can call set with other types of objects as the first arg can we?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

those cases are handled by set itself

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe trySet could be deprecated because it is using set anyway with last parameter as true ?

Copy link
Contributor Author

@bekzod bekzod Oct 2, 2017

Choose a reason for hiding this comment

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

or it should be renamed to trySetPath because it only works with path :), trySet(undefined, 'prop', 'val') will still blowup in production currently

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added isDestroyed check too

let newRoot = getPath(root, newPath);

if (newRoot) {
if (newRoot !== null && newRoot !== undefined && !newRoot.isDestroyed) {
Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't be hard coding .isDestroyed check here. We moved the flag into meta, we should use that...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe that worth another PR, or I should fix with this one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bekzod
Copy link
Contributor Author

bekzod commented Jun 8, 2018

ping this can be merged I think

} else if (!tolerant) {
throw new EmberError(
`Property set failed: object in path "${newPath}" could not be found or was destroyed.`
`Property set failed: object in path "${newPath}" could not be found.`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@mmun
Copy link
Member

mmun commented Jun 8, 2018

I think you need to update the "set with path - deprecated" test

@rwjblue rwjblue merged commit 6e3d454 into emberjs:master Jun 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants