From 44c9261360f4390f9971bb753fcfe89348c896bc Mon Sep 17 00:00:00 2001 From: Patty RoDee Date: Thu, 26 Jul 2018 15:07:37 -0700 Subject: [PATCH] feat(tab): Remove activation event emitting (#3242) --- packages/mdc-tab/README.md | 2 -- packages/mdc-tab/adapter.js | 5 ----- packages/mdc-tab/constants.js | 1 - packages/mdc-tab/foundation.js | 2 -- packages/mdc-tab/index.js | 1 - test/unit/mdc-tab/foundation.test.js | 8 +------- test/unit/mdc-tab/mdc-tab.test.js | 9 --------- 7 files changed, 1 insertion(+), 27 deletions(-) diff --git a/packages/mdc-tab/README.md b/packages/mdc-tab/README.md index b8ab8e375cc..845f923808c 100644 --- a/packages/mdc-tab/README.md +++ b/packages/mdc-tab/README.md @@ -130,7 +130,6 @@ Method Signature | Description Event Name | Event Data Structure | Description --- | --- | --- `MDCTab:interacted` | `{"detail": {"tab": MDCTab}}` | Emitted when the Tab is interacted with, regardless of its active state. Used by parent components to know which Tab to activate. -`MDCTab:activated` | `{"detail": {"tab": MDCTab}}` | Emitted when the Tab is activated. Listen for this to update content when a Tab becomes active. ## Usage within Web Frameworks @@ -154,7 +153,6 @@ Method Signature | Description `getContentOffsetLeft() => number` | Returns the `offsetLeft` value of the content element. `getContentOffsetWidth() => number` | Returns the `offsetWidth` value of the content element. `notifyInteracted() => void` | Emits the `MDCTab:interacted` event. -`notifyActivated() => void` | Emits the `MDCTab:activated` event. `focus() => void` | Applies focus to the root element. ### `MDCTabFoundation` diff --git a/packages/mdc-tab/adapter.js b/packages/mdc-tab/adapter.js index 32b89cec0dc..3ee5b6caa6f 100644 --- a/packages/mdc-tab/adapter.js +++ b/packages/mdc-tab/adapter.js @@ -96,11 +96,6 @@ class MDCTabAdapter { */ notifyInteracted() {} - /** - * Emits the MDCTab:activated event for use by parent components - */ - notifyActivated() {} - /** * Returns the offsetLeft value of the root element. * @return {number} diff --git a/packages/mdc-tab/constants.js b/packages/mdc-tab/constants.js index 97b68785076..ebfaf14a204 100644 --- a/packages/mdc-tab/constants.js +++ b/packages/mdc-tab/constants.js @@ -30,7 +30,6 @@ const strings = { TAB_INDICATOR_SELECTOR: '.mdc-tab-indicator', TABINDEX: 'tabIndex', INTERACTED_EVENT: 'MDCTab:interacted', - ACTIVATED_EVENT: 'MDCTab:activated', }; export { diff --git a/packages/mdc-tab/foundation.js b/packages/mdc-tab/foundation.js index 8a4c6366b93..8fd7829535a 100644 --- a/packages/mdc-tab/foundation.js +++ b/packages/mdc-tab/foundation.js @@ -57,7 +57,6 @@ class MDCTabFoundation extends MDCFoundation { deactivateIndicator: () => {}, computeIndicatorClientRect: () => {}, notifyInteracted: () => {}, - notifyActivated: () => {}, getOffsetLeft: () => {}, getOffsetWidth: () => {}, getContentOffsetLeft: () => {}, @@ -129,7 +128,6 @@ class MDCTabFoundation extends MDCFoundation { this.adapter_.setAttr(strings.TABINDEX, '0'); this.adapter_.activateIndicator(previousIndicatorClientRect); this.adapter_.focus(); - this.adapter_.notifyActivated(); } /** diff --git a/packages/mdc-tab/index.js b/packages/mdc-tab/index.js index 3e1e81ac4d2..cf4dacb4dff 100644 --- a/packages/mdc-tab/index.js +++ b/packages/mdc-tab/index.js @@ -90,7 +90,6 @@ class MDCTab extends MDCComponent { deactivateIndicator: () => this.tabIndicator_.deactivate(), computeIndicatorClientRect: () => this.tabIndicator_.computeContentClientRect(), notifyInteracted: () => this.emit(MDCTabFoundation.strings.INTERACTED_EVENT, {tab: this}, true /* bubble */), - notifyActivated: () => this.emit(MDCTabFoundation.strings.ACTIVATED_EVENT, {tab: this}, true /* bubble */), getOffsetLeft: () => this.root_.offsetLeft, getOffsetWidth: () => this.root_.offsetWidth, getContentOffsetLeft: () => this.content_.offsetLeft, diff --git a/test/unit/mdc-tab/foundation.test.js b/test/unit/mdc-tab/foundation.test.js index 9b03d103954..c604cbeba05 100644 --- a/test/unit/mdc-tab/foundation.test.js +++ b/test/unit/mdc-tab/foundation.test.js @@ -38,7 +38,7 @@ test('defaultAdapter returns a complete adapter implementation', () => { 'setAttr', 'activateIndicator', 'deactivateIndicator', 'computeIndicatorClientRect', 'getOffsetLeft', 'getOffsetWidth', 'getContentOffsetLeft', 'getContentOffsetWidth', - 'notifyInteracted', 'notifyActivated', + 'notifyInteracted', 'focus', ]); }); @@ -95,12 +95,6 @@ test('#activate focuses the root node', () => { td.verify(mockAdapter.focus()); }); -test(`#activate emits the ${MDCTabFoundation.strings.ACTIVATED_EVENT} event`, () => { - const {foundation, mockAdapter} = setupTest(); - foundation.activate(); - td.verify(mockAdapter.notifyActivated()); -}); - test('#computeIndicatorClientRect calls computeIndicatorClientRect on the adapter', () => { const {foundation, mockAdapter} = setupTest(); foundation.computeIndicatorClientRect(); diff --git a/test/unit/mdc-tab/mdc-tab.test.js b/test/unit/mdc-tab/mdc-tab.test.js index c92f7137fa3..2161cc0d081 100644 --- a/test/unit/mdc-tab/mdc-tab.test.js +++ b/test/unit/mdc-tab/mdc-tab.test.js @@ -159,15 +159,6 @@ test(`#adapter.notifyInteracted() emits the ${MDCTabFoundation.strings.INTERACTE td.verify(handler(td.matchers.anything())); }); -test(`#adapter.notifyActivated() emits the ${MDCTabFoundation.strings.ACTIVATED_EVENT} event`, () => { - const {component} = setupTest(); - const handler = td.func('interaction handler'); - - component.listen(MDCTabFoundation.strings.ACTIVATED_EVENT, handler); - component.getDefaultFoundation().adapter_.notifyActivated(); - td.verify(handler(td.matchers.anything())); -}); - function setupMockFoundationTest(root = getFixture()) { const MockFoundationConstructor = td.constructor(MDCTabFoundation); const mockFoundation = new MockFoundationConstructor();