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

Commit 0ce8a57

Browse files
crisbetokara
authored andcommitted
fix(build): fix errors on angular 1.3 (#9663)
* Fixes a test in the autocomplete that was failing, because it wasn't triggering a digest. * Adds a shim for `$q.resolve`, which was first introduced in Angular 1.4.1, in order to prevent similar errors in the future.
1 parent b3133f0 commit 0ce8a57

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

src/components/autocomplete/autocomplete.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ describe('<md-autocomplete>', function() {
982982
ctrl.focus();
983983

984984
// Set our search text to a value to make md-scroll-mask added to DOM
985-
scope.searchText = 'searchText';
985+
scope.$apply('searchText = "searchText"');
986986

987987
$timeout.flush();
988988

src/core/core.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ function DetectNgTouch($log, $injector) {
3434
*/
3535
function MdCoreConfigure($provide, $mdThemingProvider) {
3636

37-
$provide.decorator('$$rAF', ["$delegate", rAFDecorator]);
37+
$provide.decorator('$$rAF', ['$delegate', rAFDecorator]);
38+
$provide.decorator('$q', ['$delegate', qDecorator]);
3839

3940
$mdThemingProvider.theme('default')
4041
.primaryPalette('indigo')
@@ -76,3 +77,21 @@ function rAFDecorator($delegate) {
7677
};
7778
return $delegate;
7879
}
80+
81+
/**
82+
* @ngInject
83+
*/
84+
function qDecorator($delegate) {
85+
/**
86+
* Adds a shim for $q.resolve for Angular version that don't have it,
87+
* so we don't have to think about it.
88+
*
89+
* via https://github.com/angular/angular.js/pull/11987
90+
*/
91+
92+
// TODO(crisbeto): this won't be necessary once we drop Angular 1.3
93+
if (!$delegate.resolve) {
94+
$delegate.resolve = $delegate.when;
95+
}
96+
return $delegate;
97+
}

src/core/core.spec.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ describe('material.core', function() {
2020

2121
});
2222

23-
23+
it('should shim $q.resolve', inject(function($q) {
24+
expect(angular.isFunction($q.resolve)).toBe(true);
25+
expect($q.resolve).toBe($q.when);
26+
}));
2427
});
2528

0 commit comments

Comments
 (0)