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

cleanup _getPath #15692

Merged
merged 2 commits into from
Jun 8, 2018
Merged

cleanup _getPath #15692

merged 2 commits into from
Jun 8, 2018

Conversation

bekzod
Copy link
Contributor

@bekzod bekzod commented Oct 2, 2017

No description provided.

@@ -74,24 +68,20 @@ export function _getPath(root, path) {
let parts = path.split('.');

for (let i = 0; i < parts.length; i++) {
if (!isGettable(obj)) {
if (obj === undefined || obj === null || obj.isDestroyed) {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we want to hard code .isDestroyed check here. In theory it would be better to let m = peekMeta(obj); m.isDestroyed().

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is how done before https://github.com/emberjs/ember.js/blob/master/packages/ember-metal/lib/property_get.js#L83 <- just moved this check to top
I think checking isDestroyed with meta worth another PR since hardcoded isDestroyed check is done in more places

Copy link
Contributor Author

@bekzod bekzod Dec 9, 2017

Choose a reason for hiding this comment

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

I will do follow up PR to use meta.isDestroyed() does it sound good ? or should I do it here

Copy link
Member

Choose a reason for hiding this comment

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

Ya, sounds good to do separately

@@ -5,12 +5,6 @@
import { assert } from 'ember-debug';
import { isPath } from './path_cache';

const ALLOWABLE_TYPES = {
Copy link
Member

Choose a reason for hiding this comment

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

Why is this removed?

Copy link
Contributor Author

@bekzod bekzod Oct 5, 2017

Choose a reason for hiding this comment

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

why to have it :P, even if other types passed get will return undefined , get is working without ALLOWABLE_TYPES why to have it in _getPath

Copy link
Member

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.

added test for those cases if something missing will add it, I think all cases handled correctly

@bekzod bekzod force-pushed the cleanup-getpath branch 4 times, most recently from 21f4054 to 28c902d Compare October 5, 2017 13:37
@rwjblue rwjblue requested a review from mmun February 24, 2018 03:24
@mmun mmun self-assigned this Feb 25, 2018
@bekzod bekzod force-pushed the cleanup-getpath branch from fb17285 to 1e9796d Compare June 7, 2018 19:11
@bekzod bekzod force-pushed the cleanup-getpath branch from 1e9796d to a221b0a Compare June 8, 2018 07:51
@bekzod
Copy link
Contributor Author

bekzod commented Jun 8, 2018

ping, any objections to this ?

@bekzod bekzod force-pushed the cleanup-getpath branch from a221b0a to 4d576b0 Compare June 8, 2018 07:59
@@ -178,24 +172,16 @@ export function _getPath<T extends object>(root: T, path: string): any {
let parts = path.split('.');

for (let i = 0; i < parts.length; i++) {
if (!isGettable(obj)) {
if (obj === undefined || obj === null || (obj as MaybeHasIsDestroyed).isDestroyed) {
Copy link
Contributor Author

@bekzod bekzod Jun 8, 2018

Choose a reason for hiding this comment

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

maybe move (obj as MaybeHasIsDestroyed).isDestroyed to get itself ?

@mmun mmun merged commit 720cb17 into emberjs:master Jun 8, 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