Skip to content

Commit

Permalink
Merge pull request #15668 from bekzod/get-cleanup
Browse files Browse the repository at this point in the history
cleanup `get` helper
  • Loading branch information
rwjblue authored Sep 14, 2017
2 parents b27344a + 53eeb0b commit f692763
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions packages/ember-glimmer/lib/helpers/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import {
isConst,
referenceFromParts
} from '@glimmer/reference';
import {
NULL_REFERENCE
} from '@glimmer/runtime';


/**
@module ember
Expand Down Expand Up @@ -77,7 +81,7 @@ class GetHelperReference extends CachedReference {
this.pathReference = pathReference;

this.lastPath = null;
this.innerReference = null;
this.innerReference = NULL_REFERENCE;

let innerTag = this.innerTag = new UpdatableTag(CONSTANT_TAG);

Expand All @@ -94,19 +98,21 @@ class GetHelperReference extends CachedReference {
let pathType = typeof path;

if (pathType === 'string') {
innerReference = this.innerReference = referenceFromParts(this.sourceReference, path.split('.'));
innerReference = referenceFromParts(this.sourceReference, path.split('.'));
} else if (pathType === 'number') {
innerReference = this.innerReference = this.sourceReference.get('' + path);
innerReference = this.sourceReference.get('' + path);
}

innerTag.update(innerReference.tag);
} else {
innerReference = this.innerReference = null;
innerReference = NULL_REFERENCE;
innerTag.update(CONSTANT_TAG);
}

this.innerReference = innerReference;
}

return innerReference ? innerReference.value() : null;
return innerReference.value();
}

[UPDATE](value) {
Expand Down

0 comments on commit f692763

Please sign in to comment.