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

Commit b6b9a5c

Browse files
Splaktarmmalerba
authored andcommitted
refactor(virtual-repeat,util): lint and JSDoc cleanup (#11374)
<!-- 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 [x] 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? There is invalid JSDoc, missing JSDoc, and lint issues. <!-- Please describe the current behavior that you are modifying and link to one or more relevant issues. --> Issue Number: N/A ## What is the new behavior? JSDoc is improved. Link issues resolved. ## 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 33652b4 commit b6b9a5c

File tree

2 files changed

+29
-19
lines changed

2 files changed

+29
-19
lines changed

src/components/virtualRepeat/virtual-repeater.js

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ function virtualRepeatContainerTemplate($element) {
9696
var NUM_EXTRA = 3;
9797

9898
/** @ngInject */
99-
function VirtualRepeatContainerController($$rAF, $mdUtil, $mdConstant, $parse, $rootScope, $window, $scope,
100-
$element, $attrs) {
99+
function VirtualRepeatContainerController($$rAF, $mdUtil, $mdConstant, $parse, $rootScope, $window,
100+
$scope, $element, $attrs) {
101101
this.$rootScope = $rootScope;
102102
this.$scope = $scope;
103103
this.$element = $element;
@@ -241,7 +241,10 @@ VirtualRepeatContainerController.prototype.getScrollSize = function() {
241241
return this.scrollSize;
242242
};
243243

244-
244+
/**
245+
* @returns {string} either width or height dimension
246+
* @private
247+
*/
245248
VirtualRepeatContainerController.prototype.getDimensionName_ = function() {
246249
return this.isHorizontal() ? 'width' : 'height';
247250
};
@@ -378,7 +381,7 @@ VirtualRepeatContainerController.prototype.resetScroll = function() {
378381

379382

380383
VirtualRepeatContainerController.prototype.handleScroll_ = function() {
381-
var ltr = document.dir != 'rtl' && document.body.dir != 'rtl';
384+
var ltr = document.dir !== 'rtl' && document.body.dir !== 'rtl';
382385
if(!ltr && !this.maxSize) {
383386
this.scroller.scrollLeft = this.scrollSize;
384387
this.maxSize = this.scroller.scrollLeft;
@@ -481,8 +484,8 @@ VirtualRepeatContainerController.prototype.handleScroll_ = function() {
481484
* </md-virtual-repeat-container>
482485
* </hljs>
483486
*
484-
* @param {expression=} md-extra-name Evaluates to an additional name to which the current iterated item
485-
* can be assigned on the repeated scope (needed for use in `md-autocomplete`).
487+
* @param {expression=} md-extra-name Evaluates to an additional name to which the current iterated
488+
* item can be assigned on the repeated scope (needed for use in `md-autocomplete`).
486489
* @param {number=} md-item-size Optional height or width of the repeated elements (which **must be
487490
* identical for each element**). Virtual repeat will attempt to read the size from the DOM,
488491
* if missing, but it still assumes that all repeated nodes have the **same height**
@@ -492,8 +495,8 @@ VirtualRepeatContainerController.prototype.handleScroll_ = function() {
492495
*
493496
* **NOTE:** This object **must** implement the following interface with two methods:
494497
*
495-
* - `getItemAtIndex` - `{function(index): Object}`: The item at that `index` or `null` if it is not
496-
* yet loaded (it should start downloading the item in that case).
498+
* - `getItemAtIndex` - `{function(index): Object}`: The item at that `index` or `null` if it is
499+
* not yet loaded (it should start downloading the item in that case).
497500
* - `getLength` - `{function(): number}`: The data length to which the repeater container
498501
* should be sized. Ideally, when the count is known, this method should return it.
499502
* Otherwise, return a higher number than the currently loaded items to produce an
@@ -650,7 +653,7 @@ VirtualRepeatController.prototype.readItemSize_ = function() {
650653
/**
651654
* Returns the user-specified repeat list, transforming it into an array-like
652655
* object in the case of infinite scroll/dynamic load mode.
653-
* @param {!angular.Scope} The scope.
656+
* @param {!angular.Scope} scope The scope.
654657
* @return {!Array|!Object} An array or array-like object for iteration.
655658
*/
656659
VirtualRepeatController.prototype.repeatListExpression_ = function(scope) {
@@ -736,8 +739,8 @@ VirtualRepeatController.prototype.getItemCount = function() {
736739
/**
737740
* Updates the order and visible offset of repeated blocks in response to scrolling
738741
* or updates to `items`.
739-
* @param items {Array} visible elements
740-
* @param oldItems {Array} previously visible elements
742+
* @param {Array} items visible elements
743+
* @param {Array} oldItems previously visible elements
741744
* @private
742745
*/
743746
VirtualRepeatController.prototype.virtualRepeatUpdate_ = function(items, oldItems) {
@@ -957,13 +960,15 @@ VirtualRepeatController.prototype.updateIndexes_ = function() {
957960

958961
/**
959962
* This VirtualRepeatModelArrayLike class enforces the interface requirements
960-
* for infinite scrolling within a mdVirtualRepeatContainer. An object with this
961-
* interface must implement the following interface with two (2) methods:
963+
* for infinite scrolling within a mdVirtualRepeatContainer.
964+
*
965+
* @param {Object} model An object with this interface must implement the following interface with
966+
* two (2) methods:
962967
*
963968
* getItemAtIndex: function(index) -> item at that index or null if it is not yet
964969
* loaded (It should start downloading the item in that case).
965970
*
966-
* getLength: function() -> number The data legnth to which the repeater container
971+
* getLength: function() -> number The data length to which the repeater container
967972
* should be sized. Ideally, when the count is known, this method should return it.
968973
* Otherwise, return a higher number than the currently loaded items to produce an
969974
* infinite-scroll behavior.
@@ -981,14 +986,17 @@ VirtualRepeatController.prototype.updateIndexes_ = function() {
981986
function VirtualRepeatModelArrayLike(model) {
982987
if (!angular.isFunction(model.getItemAtIndex) ||
983988
!angular.isFunction(model.getLength)) {
984-
throw Error('When md-on-demand is enabled, the Object passed to md-virtual-repeat must implement ' +
985-
'functions getItemAtIndex() and getLength() ');
989+
throw Error('When md-on-demand is enabled, the Object passed to md-virtual-repeat must ' +
990+
'implement functions getItemAtIndex() and getLength().');
986991
}
987992

988993
this.model = model;
989994
}
990995

991-
996+
/**
997+
* @param {number} start
998+
* @param {number} end
999+
*/
9921000
VirtualRepeatModelArrayLike.prototype.$$includeIndexes = function(start, end) {
9931001
for (var i = start; i < end; i++) {
9941002
if (!this.hasOwnProperty(i)) {

src/core/util/util.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -655,8 +655,10 @@ function UtilFactory($document, $timeout, $compile, $rootScope, $$mdAnimate, $in
655655
* nextTick() coalesces all calls within a single frame
656656
* to minimize $digest thrashing
657657
*
658-
* @param callback
659-
* @param digest
658+
* @param {Function} callback function to be called after the tick
659+
* @param {boolean} digest true to call $rootScope.$digest() after callback
660+
* @param scope scope associated with callback. If the scope is destroyed, the callback will
661+
* be skipped.
660662
* @returns {*}
661663
*/
662664
nextTick: function(callback, digest, scope) {

0 commit comments

Comments
 (0)