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

Commit a17ef4f

Browse files
committed
docs(tabs): improve correctness of API docs and types
- re-add missing `md-no-disconnect` API docs, but mark the API deprecated - improve JSDoc - add missing parameters - remove invalid parameters Fixes #10407
1 parent 11f65e3 commit a17ef4f

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

src/components/tabs/js/tabsController.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,11 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp
6363
defineBooleanAttribute('dynamicHeight', handleDynamicHeight);
6464
defineBooleanAttribute('noPagination');
6565
defineBooleanAttribute('swipeContent');
66+
// TODO remove noDisconnect in 1.2.0
6667
defineBooleanAttribute('noDisconnect');
6768
defineBooleanAttribute('autoselect');
6869
defineBooleanAttribute('noSelectClick');
69-
defineBooleanAttribute('centerTabs', handleCenterTabs, false);
70+
defineBooleanAttribute('centerTabs', handleCenterTabs);
7071
defineBooleanAttribute('enableDisconnect');
7172

7273
// Define public properties
@@ -146,11 +147,11 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp
146147
* Defines boolean attributes with default value set to true. I.e. md-stretch-tabs with no value
147148
* will be treated as being truthy.
148149
* @param {string} key
149-
* @param {Function} handler
150+
* @param {Function=} handler
150151
*/
151152
function defineBooleanAttribute (key, handler) {
152153
var attr = $attrs.$normalize('md-' + key);
153-
if (handler) defineProperty(key, handler);
154+
if (handler) defineProperty(key, handler, undefined);
154155
if ($attrs.hasOwnProperty(attr)) updateValue($attrs[attr]);
155156
$attrs.$observe(attr, updateValue);
156157
function updateValue (newValue) {
@@ -448,6 +449,7 @@ function MdTabsController ($scope, $element, $window, $mdConstant, $mdTabInkRipp
448449
isActive: function () { return this.getIndex() === ctrl.selectedIndex; },
449450
isLeft: function () { return this.getIndex() < ctrl.selectedIndex; },
450451
isRight: function () { return this.getIndex() > ctrl.selectedIndex; },
452+
// TODO remove reference to noDisconnect in 1.2.0
451453
shouldRender: function () { return !ctrl.noDisconnect || this.isActive(); },
452454
hasFocus: function () {
453455
return ctrl.styleTabItemFocus

src/components/tabs/js/tabsDirective.js

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,26 +66,29 @@
6666
* `always` | stretched | stretched
6767
* `never` | --- | ---
6868
*
69-
* @param {integer=} md-selected Index of the active/selected tab.
70-
* @param {boolean=} md-no-ink-bar If present, disables the selection ink bar.
71-
* @param {string=} md-align-tabs Attribute to indicate position of tab buttons: `bottom` or `top`;
69+
* @param {number=} md-selected Index of the active/selected tab.
70+
* @param {expression=} md-no-ink-bar If `true` or no value, disables the selection ink bar.
71+
* @param {string=} md-align-tabs Attribute to indicate position of tab buttons: `bottom` or `top`;
7272
* Default is `top`.
7373
* @param {string=} md-stretch-tabs Attribute to indicate whether or not to stretch tabs: `auto`,
7474
* `always`, or `never`; Default is `auto`.
75-
* @param {boolean=} md-dynamic-height When enabled, the tab wrapper will resize based on the
76-
* contents of the selected tab.
77-
* @param {boolean=} md-border-bottom If present, shows a solid `1px` border between the tabs and
78-
* their content.
79-
* @param {boolean=} md-center-tabs If defined, tabs will be centered provided there is no need
80-
* for pagination.
81-
* @param {boolean=} md-no-pagination When enabled, pagination will remain off.
82-
* @param {boolean=} md-swipe-content When enabled, swipe gestures will be enabled for the content
75+
* @param {expression=} md-dynamic-height If `true` or no value, the tab wrapper will resize based
76+
* on the contents of the selected tab.
77+
* @param {boolean=} md-border-bottom If the attribute is present, shows a solid `1px` border
78+
* between the tabs and their content.
79+
* @param {boolean=} md-center-tabs If the attribute is present, tabs will be centered provided
80+
* there is no need for pagination.
81+
* @param {boolean=} md-no-pagination If the attribute is present, pagination will remain off.
82+
* @param {expression=} md-swipe-content When enabled, swipe gestures will be enabled for the content
8383
* area to allow swiping between tabs.
8484
* @param {boolean=} md-enable-disconnect When enabled, scopes will be disconnected for tabs that
8585
* are not being displayed. This provides a performance boost, but may also cause unexpected
8686
* issues. It is not recommended for most users.
87-
* @param {boolean=} md-autoselect When present, any tabs added after the initial load will be
88-
* automatically selected.
87+
* @param {boolean=} md-no-disconnect **Deprecated**: If your tab content has background tasks
88+
* (ie. event listeners), you will want to include this to prevent the scope from being
89+
* disconnected.
90+
* @param {boolean=} md-autoselect If the attribute is present, any tabs added after the initial
91+
* load will be automatically selected.
8992
* @param {boolean=} md-no-select-click When true, click events will not be fired when the value of
9093
* `md-active` on an `md-tab` changes. This is useful when using tabs with UI-Router's child
9194
* states, as triggering a click event in that case can cause an extra tab change to occur.

0 commit comments

Comments
 (0)