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

Commit 33652b4

Browse files
Splaktarmmalerba
authored andcommitted
perf(tabs): remove unreferenced elements variable from TabsController (#11379)
<!-- Filling out this template is required! Do not delete it when submitting a Pull Request! Without this information, your Pull Request may be auto-closed. --> ## PR Checklist Please check that your PR fulfills the following requirements: - [x] The commit message follows [our guidelines](https://github.com/angular/material/blob/master/.github/CONTRIBUTING.md#-commit-message-format) - [x] Tests for the changes have been added or this is not a bug fix / enhancement - [x] Docs have been added, updated, or were not required ## PR Type What kind of change does this PR introduce? <!-- Please check the one that applies to this PR using "x". --> ``` [ ] Bugfix [ ] Enhancement [ ] Documentation content changes [ ] Code style update (formatting, local variables) [x] Refactoring (no functional changes, no api changes) [ ] Build related changes [ ] CI related changes [ ] Infrastructure changes [ ] Other... Please describe: ``` ## What is the current behavior? The `MdTabsController` initializes `var elements = getElements()` at the top of the controller and again in `setupTabsController ()` but that `elements` variable is no longer referenced as all of the code has been updated to call `getElements()` each time instead. <!-- Please describe the current behavior that you are modifying and link to one or more relevant issues. --> Issue Number: Fixes #11377 ## What is the new behavior? Remove this unused and unreferenced variable to avoid extra DOM lookups. ## Does this PR introduce a breaking change? ``` [ ] Yes [x] No ``` <!-- If this PR contains a breaking change, please describe the impact and migration path for existing applications below. --> <!-- Note that breaking changes are highly unlikely to get merged to master unless the validation is clear and the use case is critical. --> ## Other information
1 parent d48c5b8 commit 33652b4

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/components/tabs/js/tabsController.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,10 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp
1111
// define private properties
1212
var ctrl = this,
1313
locked = false,
14-
elements = getElements(),
1514
queue = [],
1615
destroyed = false,
1716
loaded = false;
1817

19-
2018
// Define public methods
2119
ctrl.$onInit = $onInit;
2220
ctrl.updatePagination = $mdUtil.debounce(updatePagination, 100);
@@ -94,10 +92,6 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp
9492
bindEvents();
9593
$mdTheming($element);
9694
$mdUtil.nextTick(function () {
97-
// Note that the element references need to be updated, because certain "browsers"
98-
// (IE/Edge) lose them and start throwing "Invalid calling object" errors, when we
99-
// compile the element contents down in `compileElement`.
100-
elements = getElements();
10195
updateHeightFromContent();
10296
adjustOffset();
10397
updateInkBarStyles();
@@ -469,7 +463,7 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp
469463

470464
/**
471465
* Gathers references to all of the DOM elements used by this controller.
472-
* @returns {{}}
466+
* @returns {Object}
473467
*/
474468
function getElements () {
475469
var elements = {};
@@ -716,7 +710,7 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp
716710
extraOffset = 32;
717711

718712
// If we are selecting the first tab (in LTR and RTL), always set the offset to 0
719-
if (index == 0) {
713+
if (index === 0) {
720714
ctrl.offsetLeft = 0;
721715
return;
722716
}
@@ -926,6 +920,6 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp
926920
}
927921

928922
function isRtl() {
929-
return ($mdUtil.bidi() == 'rtl');
923+
return ($mdUtil.bidi() === 'rtl');
930924
}
931925
}

0 commit comments

Comments
 (0)