Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

Commit

Permalink
refactor(autofocus): remove deprecated md-auto-focus attribute
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Removed the deprecated `md-auto-focus` directive. It was deprecated in favor of `md-autofocus`. Please see the [md-autofocus Docs](https://material.angularjs.org/latest/api/directive/mdAutofocus) for examples.
  • Loading branch information
Splaktar committed Jul 27, 2020
1 parent 8fc36d4 commit bf0ec8c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 28 deletions.
5 changes: 1 addition & 4 deletions src/core/util/autofocus.js
@@ -1,8 +1,5 @@
angular.module('material.core')
.directive('mdAutofocus', MdAutofocusDirective)

// Support the deprecated md-auto-focus as well
.directive('mdAutoFocus', MdAutofocusDirective);
.directive('mdAutofocus', MdAutofocusDirective);

/**
* @ngdoc directive
Expand Down
11 changes: 3 additions & 8 deletions src/core/util/util.js
Expand Up @@ -222,14 +222,9 @@ function UtilFactory($document, $timeout, $compile, $rootScope, $$mdAnimate, $in

elToFocus = scanForFocusable(containerEl, attributeVal || AUTO_FOCUS);

if (!elToFocus && attributeVal !== AUTO_FOCUS) {
// Scan for deprecated attribute
elToFocus = scanForFocusable(containerEl, this.prefixer('md-auto-focus', true));

if (!elToFocus) {
// Scan for fallback to 'universal' API
elToFocus = scanForFocusable(containerEl, AUTO_FOCUS);
}
// Scan for fallback to 'universal' API
if (!elToFocus) {
elToFocus = scanForFocusable(containerEl, AUTO_FOCUS);
}

return elToFocus;
Expand Down
16 changes: 0 additions & 16 deletions src/core/util/util.spec.js
Expand Up @@ -122,22 +122,6 @@ describe('util', function() {
expect(target[0].nodeName).toBe("BUTTON");
}));

it('should find valid a valid focusTarget with "md-auto-focus"', inject(function($rootScope, $compile, $mdUtil) {
var widget = $compile('<div class="autoFocus"><button md-auto-focus><img></button></div>')($rootScope);
$rootScope.$apply();
var target = $mdUtil.findFocusTarget(widget);

expect(target[0].nodeName).toBe("BUTTON");
}));

it('should find valid a valid focusTarget with "md-auto-focus" argument', inject(function($rootScope, $compile, $mdUtil) {
var widget = $compile('<div class="autoFocus"><button md-autofocus><img></button></div>')($rootScope);
$rootScope.$apply();
var target = $mdUtil.findFocusTarget(widget,'[md-auto-focus]');

expect(target[0].nodeName).toBe("BUTTON");
}));

it('should find valid a valid focusTarget with a deep "md-autofocus" argument', inject(function($rootScope, $compile, $mdUtil) {
var widget = $compile('<div class="autoFocus"><md-sidenav><button md-autofocus><img></button></md-sidenav></div>')($rootScope);
$rootScope.$apply();
Expand Down

0 comments on commit bf0ec8c

Please sign in to comment.