fix(upgrade): Ensure upgrade adapter works on angular.js 1.2 (#8647)
This commit is contained in:
parent
420e83a396
commit
cbc8d0adf8
@ -319,7 +319,8 @@ export class UpgradeAdapter {
|
|||||||
.value(NG2_COMPONENT_FACTORY_REF_MAP, componentFactoryRefMap)
|
.value(NG2_COMPONENT_FACTORY_REF_MAP, componentFactoryRefMap)
|
||||||
.config([
|
.config([
|
||||||
'$provide',
|
'$provide',
|
||||||
(provide) => {
|
'$injector',
|
||||||
|
(provide, ng1Injector) => {
|
||||||
provide.decorator(NG1_ROOT_SCOPE, [
|
provide.decorator(NG1_ROOT_SCOPE, [
|
||||||
'$delegate',
|
'$delegate',
|
||||||
function(rootScopeDelegate: angular.IRootScopeService) {
|
function(rootScopeDelegate: angular.IRootScopeService) {
|
||||||
@ -333,27 +334,29 @@ export class UpgradeAdapter {
|
|||||||
return rootScope = rootScopeDelegate;
|
return rootScope = rootScopeDelegate;
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
provide.decorator(NG1_TESTABILITY, [
|
if (ng1Injector.has(NG1_TESTABILITY)) {
|
||||||
'$delegate',
|
provide.decorator(NG1_TESTABILITY, [
|
||||||
function(testabilityDelegate: angular.ITestabilityService) {
|
'$delegate',
|
||||||
var ng2Testability: Testability = injector.get(Testability);
|
function(testabilityDelegate: angular.ITestabilityService) {
|
||||||
|
var ng2Testability: Testability = injector.get(Testability);
|
||||||
|
|
||||||
var origonalWhenStable: Function = testabilityDelegate.whenStable;
|
var origonalWhenStable: Function = testabilityDelegate.whenStable;
|
||||||
var newWhenStable = (callback: Function): void => {
|
var newWhenStable = (callback: Function): void => {
|
||||||
var whenStableContext: any = this;
|
var whenStableContext: any = this;
|
||||||
origonalWhenStable.call(this, function() {
|
origonalWhenStable.call(this, function() {
|
||||||
if (ng2Testability.isStable()) {
|
if (ng2Testability.isStable()) {
|
||||||
callback.apply(this, arguments);
|
callback.apply(this, arguments);
|
||||||
} else {
|
} else {
|
||||||
ng2Testability.whenStable(newWhenStable.bind(whenStableContext, callback));
|
ng2Testability.whenStable(newWhenStable.bind(whenStableContext, callback));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
testabilityDelegate.whenStable = newWhenStable;
|
testabilityDelegate.whenStable = newWhenStable;
|
||||||
return testabilityDelegate;
|
return testabilityDelegate;
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user