Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
get(obj: object, keyName: string): any {
let ret: any;
let propertyTag = tagForProperty(obj, keyName) as UpdatableTag;
// We don't use the tag since CPs are not automatic, we just want to avoid
// anything tracking while we get the altKey
untrack(() => {
ret = get(obj, this.altKey);
});
let lastRevision = getLastRevisionFor(obj, keyName);
if (!validate(propertyTag, lastRevision)) {
update(propertyTag, combine(getChainTagsForKey(obj, this.altKey)));
setLastRevisionFor(obj, keyName, value(propertyTag));
finishLazyChains(obj, keyName, ret);
}
consume(propertyTag);
return ret;
}
let value;
// If the field has never been initialized, we should initialize it
if (hasInitializer && !values.has(this)) {
value = initializer.call(this);
values.set(this, value);
} else {
value = values.get(this);
}
// Add the tag of the returned value if it is an array, since arrays
// should always cause updates if they are consumed and then changed
if (Array.isArray(value) || isEmberArray(value)) {
update(propertyTag, tagForProperty(value, '[]'));
}
return value;
},
if (this._volatile) {
return this.volatileSet(obj, keyName, value);
}
let ret;
try {
beginPropertyChanges();
ret = this._set(obj, keyName, value);
finishLazyChains(obj, keyName, ret);
let propertyTag = tagForProperty(obj, keyName) as UpdatableTag;
if (this._dependentKeys !== undefined) {
update(propertyTag, combine(getChainTagsForKeys(obj, this._dependentKeys)));
}
setLastRevisionFor(obj, keyName, tagValue(propertyTag));
} finally {
endPropertyChanges();
}
return ret;
}
if (lazyTags === undefined) {
return;
}
if (value === null || (typeof value !== 'object' && typeof value !== 'function')) {
for (let path in lazyTags) {
delete lazyTags[path];
}
return;
}
for (let path in lazyTags) {
let tag = lazyTags[path];
update(tag, combine(getChainTagsForKey(value, path)));
delete lazyTags[path];
}
}
export function contentFor(proxy, m) {
let content = get(proxy, 'content');
let tag = (m === undefined ? meta(proxy) : m).readableTag();
if (tag !== undefined) {
update(tag, tagFor(content));
}
return content;
}
compute() {
let { lastPath, innerReference, innerTag } = this;
let path = this.pathReference.value();
if (path !== lastPath) {
innerReference = referenceFromPath(this.sourceReference, path);
update(innerTag, innerReference.tag);
this.innerReference = innerReference;
this.lastPath = path;
}
return innerReference.value();
}
desc.get = function() {
let propertyTag = tagForProperty(this, key) as UpdatableTag;
let ret;
let tag = track(() => {
ret = originalGet!.call(this);
});
update(propertyTag, tag);
consume(tag);
return ret;
};
}
install(state: CustomModifierState) {
let { element, args, delegate, modifier, tag } = state;
let { capabilities } = delegate;
if (capabilities.disableAutoTracking === true) {
untrack(() => delegate.installModifier(modifier, element, args.value()));
} else {
let combinedTrackingTag = track(
() => delegate.installModifier(modifier, element, args.value()),
DEBUG && debugRenderMessage!(`(instance of a \`${getDebugName!(modifier)}\` modifier)`)
);
update(tag, combinedTrackingTag);
}
}
update(state: CustomModifierState) {
let { args, delegate, modifier, tag } = state;
let { capabilities } = delegate;
if (capabilities.disableAutoTracking === true) {
untrack(() => delegate.updateModifier(modifier, args.value()));
} else {
let combinedTrackingTag = track(
() => delegate.updateModifier(modifier, args.value()),
DEBUG && debugRenderMessage!(`(instance of a \`${getDebugName!(modifier)}\` modifier)`)
);
update(tag, combinedTrackingTag);
}
}