fix(change detection): preserve memoized results from pure functions
This commit is contained in:
@ -291,7 +291,7 @@ export class ChangeDetectorJITGenerator {
|
||||
|
||||
if (r.isPureFunction()) {
|
||||
var condition = r.args.map((a) => this._changeNames[a]).join(" || ");
|
||||
return `if (${condition}) { ${check} }`;
|
||||
return `if (${condition}) { ${check} } else { ${newValue} = ${oldValue}; }`;
|
||||
} else {
|
||||
return check;
|
||||
}
|
||||
|
@ -69,12 +69,11 @@ var _rootBindings = [bind(Reflector).toValue(reflector), TestabilityRegistry];
|
||||
|
||||
function _injectorBindings(appComponentType): List<Type | Binding | List<any>> {
|
||||
var bestChangeDetection: Type = DynamicChangeDetection;
|
||||
// Re-enable once all e2e tests pass
|
||||
// if (PreGeneratedChangeDetection.isSupported()) {
|
||||
// bestChangeDetection = PreGeneratedChangeDetection;
|
||||
//} else if (JitChangeDetection.isSupported()) {
|
||||
// bestChangeDetection = JitChangeDetection;
|
||||
//}
|
||||
if (PreGeneratedChangeDetection.isSupported()) {
|
||||
bestChangeDetection = PreGeneratedChangeDetection;
|
||||
} else if (JitChangeDetection.isSupported()) {
|
||||
bestChangeDetection = JitChangeDetection;
|
||||
}
|
||||
return [
|
||||
bind(DOCUMENT_TOKEN)
|
||||
.toValue(DOM.defaultDoc()),
|
||||
|
@ -352,7 +352,7 @@ class _CodegenState {
|
||||
if (r.isPureFunction()) {
|
||||
// Add an "if changed guard"
|
||||
var condition = r.args.map((a) => _changeNames[a]).join(' || ');
|
||||
return 'if ($condition) { $check }';
|
||||
return 'if ($condition) { $check } else { $newValue = $oldValue; }';
|
||||
} else {
|
||||
return check;
|
||||
}
|
||||
|
Reference in New Issue
Block a user