From 5ba7e271cd85e25855cd243726f0ecb5414486d7 Mon Sep 17 00:00:00 2001 From: "Kenneth G. Franqueiro" Date: Mon, 16 Apr 2018 16:20:36 -0400 Subject: [PATCH] chore(dialog): Remove ripple layout & layoutFooterRipples adapter API (#2570) The layoutFooterRipples dialog adapter API is no longer used and can be removed. --- packages/mdc-dialog/foundation.js | 2 -- packages/mdc-dialog/index.js | 1 - test/unit/mdc-dialog/foundation.test.js | 11 ----------- test/unit/mdc-dialog/mdc-dialog.test.js | 26 ------------------------- 4 files changed, 40 deletions(-) diff --git a/packages/mdc-dialog/foundation.js b/packages/mdc-dialog/foundation.js index c93119c3688..c2c7a83fa65 100644 --- a/packages/mdc-dialog/foundation.js +++ b/packages/mdc-dialog/foundation.js @@ -46,7 +46,6 @@ export default class MDCDialogFoundation extends MDCFoundation { trapFocusOnSurface: () => {}, untrapFocusOnSurface: () => {}, isDialog: (/* el: Element */) => /* boolean */ false, - layoutFooterRipples: () => {}, }; } @@ -138,7 +137,6 @@ export default class MDCDialogFoundation extends MDCFoundation { this.adapter_.removeClass(MDCDialogFoundation.cssClasses.ANIMATING); if (this.isOpen_) { this.adapter_.trapFocusOnSurface(); - this.adapter_.layoutFooterRipples(); } else { this.enableScroll_(); }; diff --git a/packages/mdc-dialog/index.js b/packages/mdc-dialog/index.js index d75cd75b847..49db39b54ff 100644 --- a/packages/mdc-dialog/index.js +++ b/packages/mdc-dialog/index.js @@ -83,7 +83,6 @@ export class MDCDialog extends MDCComponent { trapFocusOnSurface: () => this.focusTrap_.activate(), untrapFocusOnSurface: () => this.focusTrap_.deactivate(), isDialog: (el) => el === this.dialogSurface_, - layoutFooterRipples: () => this.footerBtnRipples_.forEach((ripple) => ripple.layout()), }); } } diff --git a/test/unit/mdc-dialog/foundation.test.js b/test/unit/mdc-dialog/foundation.test.js index c174b4c7dbf..691dab9280e 100644 --- a/test/unit/mdc-dialog/foundation.test.js +++ b/test/unit/mdc-dialog/foundation.test.js @@ -40,7 +40,6 @@ test('default adapter returns a complete adapter implementation', () => { 'registerDocumentKeydownHandler', 'deregisterDocumentKeydownHandler', 'registerTransitionEndHandler', 'deregisterTransitionEndHandler', 'notifyAccept', 'notifyCancel', 'trapFocusOnSurface', 'untrapFocusOnSurface', 'isDialog', - 'layoutFooterRipples', ]); }); @@ -158,16 +157,6 @@ test('#close deactivates focus trapping on the dialog surface', () => { td.verify(mockAdapter.untrapFocusOnSurface()); }); -test('#open calls adapter method to re-layout footer ripples', () => { - const {foundation, mockAdapter} = setupTest(); - - td.when(mockAdapter.registerTransitionEndHandler(td.callback)).thenCallback({target: {}}); - td.when(mockAdapter.isDialog(td.matchers.isA(Object))).thenReturn(true); - foundation.open(); - - td.verify(mockAdapter.layoutFooterRipples()); -}); - test('#accept closes the dialog', () => { const {foundation} = setupTest(); diff --git a/test/unit/mdc-dialog/mdc-dialog.test.js b/test/unit/mdc-dialog/mdc-dialog.test.js index b80891ed0f7..6b28a16de65 100644 --- a/test/unit/mdc-dialog/mdc-dialog.test.js +++ b/test/unit/mdc-dialog/mdc-dialog.test.js @@ -14,9 +14,6 @@ * limitations under the License. */ -// This suite requires hooks to stub (and clean up) MDCRipple#layout. -/* eslint mocha/no-hooks: "off" */ - import {assert} from 'chai'; import bel from 'bel'; import domEvents from 'dom-events'; @@ -24,7 +21,6 @@ import td from 'testdouble'; import {createMockRaf} from '../helpers/raf'; import {strings} from '../../../packages/mdc-dialog/constants'; import {MDCDialog, util} from '../../../packages/mdc-dialog'; -import {MDCRipple} from '../../../packages/mdc-ripple'; import {supportsCssVariables} from '../../../packages/mdc-ripple/util'; function getFixture() { @@ -73,22 +69,6 @@ function hasClassMatcher(className) { suite('MDCDialog'); -const originalLayout = MDCRipple.prototype.layout; -const stubbedLayout = td.func('MDCRipple#layout'); - -before(() => { - MDCRipple.prototype.layout = stubbedLayout; -}); - -afterEach(() => { - // Ensure that stubbedLayout's call count resets between tests - td.reset(); -}); - -after(() => { - MDCRipple.prototype.layout = originalLayout; -}); - test('attachTo returns a component instance', () => { assert.isOk(MDCDialog.attachTo(getFixture().querySelector('.mdc-dialog')) instanceof MDCDialog); }); @@ -332,9 +312,3 @@ test('adapter#isDialog returns false for a non-dialog surface element', () => { const {root, component} = setupTest(); assert.isNotOk(component.getDefaultFoundation().adapter_.isDialog(root)); }); - -test('adapter#layoutFooterRipples calls layout on each footer button\'s ripple instance', () => { - const {component} = setupTest(); - component.getDefaultFoundation().adapter_.layoutFooterRipples(); - td.verify(stubbedLayout(), {times: 2}); -});