Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 88bb551

Browse files
committed
fix(ngMock): attach $injector to $rootElement
Fixes #14022 Closes #14034
1 parent 3940edc commit 88bb551

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/ngMock/angular-mocks.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -2089,9 +2089,9 @@ angular.mock.$RAFDecorator = ['$delegate', function($delegate) {
20892089
*
20902090
*/
20912091
angular.mock.$RootElementProvider = function() {
2092-
this.$get = function() {
2093-
return angular.element('<div ng-app></div>');
2094-
};
2092+
this.$get = ['$injector', function($injector) {
2093+
return angular.element('<div ng-app></div>').data('$injector', $injector);
2094+
}];
20952095
};
20962096

20972097
/**

test/ngMock/angular-mocksSpec.js

+4
Original file line numberDiff line numberDiff line change
@@ -1647,6 +1647,10 @@ describe('ngMock', function() {
16471647
it('should create mock application root', inject(function($rootElement) {
16481648
expect($rootElement.text()).toEqual('');
16491649
}));
1650+
1651+
it('should attach the `$injector` to `$rootElement`', inject(function($injector, $rootElement) {
1652+
expect($rootElement.injector()).toBe($injector);
1653+
}));
16501654
});
16511655

16521656

0 commit comments

Comments
 (0)