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

Commit baa7563

Browse files
committed
refactor(sidenav): remove deprecated access to $media in md-is-locked-open
- improved layout and position of `$mdMedia` docs section in Sidenav API docs BREAKING CHANGE: Removed access for the deprecated `$media` service in `md-is-locked-open`. This was deprecated in favor of the `$mdMedia` service. The functionality is the same and only a rename to the current name of the service is required.
1 parent e3b52a0 commit baa7563

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

src/components/sidenav/sidenav.js

+15-13
Original file line numberDiff line numberDiff line change
@@ -208,18 +208,24 @@ function SidenavService($mdComponentRegistry, $mdUtil, $q, $log) {
208208
* pressing the 'Escape' key will not close the sidenav.
209209
* @param {string=} md-component-id componentId to use with $mdSidenav service.
210210
* @param {expression=} md-is-locked-open When this expression evaluates to true,
211-
* the sidenav 'locks open': it falls into the content's flow instead
212-
* of appearing over it. This overrides the `md-is-open` attribute.
213-
* @param {string=} md-disable-scroll-target Selector, pointing to an element, whose scrolling will
214-
* be disabled when the sidenav is opened. By default this is the sidenav's direct parent.
211+
* the sidenav "locks open": it falls into the content's flow instead of appearing over it. This
212+
* overrides the `md-is-open` attribute.
215213
*
216-
* The $mdMedia() service is exposed to the is-locked-open attribute, which
214+
* The `$mdMedia()` service is exposed to the `md-is-locked-open` attribute, which
217215
* can be given a media query or one of the `sm`, `gt-sm`, `md`, `gt-md`, `lg` or `gt-lg` presets.
218-
* Examples:
216+
* <br><br>Examples:
217+
*
218+
* Lock open when `true`:<br>
219+
* `<md-sidenav md-is-locked-open="shouldLockOpen"></md-sidenav>`
220+
*
221+
* Lock open when the width is `1000px` or greater:<br>
222+
* `<md-sidenav md-is-locked-open="$mdMedia('min-width: 1000px')"></md-sidenav>`
219223
*
220-
* - `<md-sidenav md-is-locked-open="shouldLockOpen"></md-sidenav>`
221-
* - `<md-sidenav md-is-locked-open="$mdMedia('min-width: 1000px')"></md-sidenav>`
222-
* - `<md-sidenav md-is-locked-open="$mdMedia('sm')"></md-sidenav>` (locks open on small screens)
224+
* Lock open on small screens:<br>
225+
* `<md-sidenav md-is-locked-open="$mdMedia('sm')"></md-sidenav>`
226+
*
227+
* @param {string=} md-disable-scroll-target Selector, pointing to an element, whose scrolling will
228+
* be disabled when the sidenav is opened. By default this is the sidenav's direct parent.
223229
*/
224230
function SidenavDirective($mdMedia, $mdUtil, $mdConstant, $mdTheming, $mdInteraction, $animate,
225231
$compile, $parse, $log, $q, $document, $window, $$rAF) {
@@ -251,10 +257,6 @@ function SidenavDirective($mdMedia, $mdUtil, $mdConstant, $mdTheming, $mdInterac
251257
var ngWindow = angular.element($window);
252258
var isLocked = function() {
253259
return isLockedOpenParsed(scope.$parent, {
254-
$media: function(arg) {
255-
$log.warn("$media is deprecated for is-locked-open. Use $mdMedia instead.");
256-
return $mdMedia(arg);
257-
},
258260
$mdMedia: $mdMedia
259261
});
260262
};

src/components/sidenav/sidenav.spec.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -169,20 +169,20 @@ describe('mdSidenav', function() {
169169
expect(el.parent().find('md-backdrop').hasClass('md-locked-open')).toBe(true);
170170
}));
171171

172-
it('should expose $mdMedia service as $media local in is-locked-open attribute', function() {
172+
it('should expose $mdMedia service as local in is-locked-open attribute', function() {
173173
var mdMediaSpy = jasmine.createSpy('$mdMedia');
174174
module(function($provide) {
175175
$provide.value('$mdMedia', mdMediaSpy);
176176
});
177177
inject(function($rootScope, $animate, $document, $mdMedia) {
178-
var el = setup('md-is-locked-open="$mdMedia(123)"');
178+
setup('md-is-locked-open="$mdMedia(123)"');
179179
expect($mdMedia).toHaveBeenCalledWith(123);
180180
});
181181
});
182182

183183
it('should trigger a resize event when opening',
184184
inject(function($rootScope, $animate, $$rAF, $window) {
185-
var el = setup('md-is-open="show"');
185+
setup('md-is-open="show"');
186186
var obj = { callback: function() {} };
187187

188188
spyOn(obj, 'callback');

0 commit comments

Comments
 (0)