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

Commit 14ab34c

Browse files
crisbetokara
authored andcommitted
chore(): move hardcoded priority value to a constant (#9791)
There are several directives that are supposed to run before `ngAria` and who have a hardcoded priority of 210. This change moves the priority to a constant so it's easier to maintain.
1 parent ff86bba commit 14ab34c

File tree

5 files changed

+12
-7
lines changed

5 files changed

+12
-7
lines changed

src/components/checkbox/checkbox.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function MdCheckboxDirective(inputDirective, $mdAria, $mdConstant, $mdTheming, $
6161
restrict: 'E',
6262
transclude: true,
6363
require: '?ngModel',
64-
priority: 210, // Run before ngAria
64+
priority: $mdConstant.BEFORE_NG_ARIA,
6565
template:
6666
'<div class="md-container" md-ink-ripple md-ink-ripple-checkbox>' +
6767
'<div class="md-icon"></div>' +

src/components/menuBar/js/menuItemDirective.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ angular
44
.directive('mdMenuItem', MenuItemDirective);
55

66
/* @ngInject */
7-
function MenuItemDirective($mdUtil, $$mdSvgRegistry) {
7+
function MenuItemDirective($mdUtil, $mdConstant, $$mdSvgRegistry) {
88
return {
99
controller: 'MenuItemController',
1010
require: ['mdMenuItem', '?ngModel'],
11-
priority: 210, // ensure that our post link runs after ngAria
11+
priority: $mdConstant.BEFORE_NG_ARIA,
1212
compile: function(templateEl, templateAttrs) {
1313
var type = templateAttrs.type;
1414
var inMenuBarClass = 'md-in-menu-bar';

src/components/switch/switch.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function MdSwitch(mdCheckboxDirective, $mdUtil, $mdConstant, $parse, $$rAF, $mdG
5151

5252
return {
5353
restrict: 'E',
54-
priority: 210, // Run before ngAria
54+
priority: $mdConstant.BEFORE_NG_ARIA,
5555
transclude: true,
5656
template:
5757
'<div class="md-container">' +

src/components/tooltip/tooltip.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ angular
3535
* @param {string=} md-direction Which direction would you like the tooltip to go? Supports left, right, top, and bottom. Defaults to bottom.
3636
*/
3737
function MdTooltipDirective($timeout, $window, $$rAF, $document, $mdUtil, $mdTheming, $animate,
38-
$interpolate, $$mdTooltipRegistry) {
38+
$interpolate, $mdConstant, $$mdTooltipRegistry) {
3939

4040
var ENTER_EVENTS = 'focus touchstart mouseenter';
4141
var LEAVE_EVENTS = 'blur touchcancel mouseleave';
@@ -46,7 +46,7 @@ function MdTooltipDirective($timeout, $window, $$rAF, $document, $mdUtil, $mdThe
4646
return {
4747
restrict: 'E',
4848
transclude: true,
49-
priority: 210, // Before ngAria
49+
priority: $mdConstant.BEFORE_NG_ARIA,
5050
template: '<div class="md-content _md" ng-transclude></div>',
5151
scope: {
5252
delay: '=?mdDelay',

src/core/util/constant.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function MdConstantFactory($sniffer, $window, $document) {
3838
isNumPadKey : function (e){ return (3 === e.location && e.keyCode >= 97 && e.keyCode <= 105); },
3939
isNavigationKey : function(e) {
4040
var kc = self.KEY_CODE, NAVIGATION_KEYS = [kc.SPACE, kc.ENTER, kc.UP_ARROW, kc.DOWN_ARROW];
41-
return (NAVIGATION_KEYS.indexOf(e.keyCode) != -1);
41+
return (NAVIGATION_KEYS.indexOf(e.keyCode) != -1);
4242
},
4343

4444
/**
@@ -49,6 +49,11 @@ function MdConstantFactory($sniffer, $window, $document) {
4949
*/
5050
ELEMENT_MAX_PIXELS: 1533917,
5151

52+
/**
53+
* Priority for a directive that should run before the directives from ngAria.
54+
*/
55+
BEFORE_NG_ARIA: 210,
56+
5257
/**
5358
* Common Keyboard actions and their associated keycode.
5459
*/

0 commit comments

Comments
 (0)