Skip to content

Commit 078e2fe

Browse files
committed
cleanup _getPath
1 parent ef2b440 commit 078e2fe

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

packages/ember-metal/lib/property_get.ts

+4-14
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ import { isPath } from './path_cache';
1111
import { tagForProperty } from './tags';
1212
import { getCurrentTracker } from './tracked';
1313

14-
const ALLOWABLE_TYPES = {
15-
object: true,
16-
function: true,
17-
string: true,
18-
};
19-
2014
export const PROXY_CONTENT = symbol('PROXY_CONTENT');
2115

2216
export let getPossibleMandatoryProxyValue: (obj: object, keyName: string) => any;
@@ -178,24 +172,20 @@ export function _getPath<T extends object>(root: T, path: string): any {
178172
let parts = path.split('.');
179173

180174
for (let i = 0; i < parts.length; i++) {
181-
if (!isGettable(obj)) {
175+
if (obj === undefined || obj === null || obj.isDestroyed) {
182176
return undefined;
183177
}
184178

185179
obj = get(obj, parts[i]);
180+
}
186181

187-
if (obj && (obj as MaybeHasIsDestroyed).isDestroyed) {
188-
return undefined;
189-
}
182+
if (obj !== undefined && obj !== null && (obj as MaybeHasIsDestroyed).isDestroyed) {
183+
return undefined;
190184
}
191185

192186
return obj;
193187
}
194188

195-
function isGettable(obj: any): boolean {
196-
return obj !== undefined && obj !== null && ALLOWABLE_TYPES[typeof obj];
197-
}
198-
199189
/**
200190
Retrieves the value of a property from an Object, or a default value in the
201191
case that the property returns `undefined`.

0 commit comments

Comments
 (0)