Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
fix(list): removed unused adapter.removeAttributeForElementIndex (#4473)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: removed #adapter.removeAttributeForElementIndex
  • Loading branch information
Matt Goo authored Mar 6, 2019
1 parent a132163 commit 6b3a419
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 31 deletions.
2 changes: 0 additions & 2 deletions packages/mdc-list/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ export interface MDCListAdapter {

setAttributeForElementIndex(index: number, attribute: string, value: string): void;

removeAttributeForElementIndex(index: number, attribute: string): void;

addClassForElementIndex(index: number, className: string): void;

removeClassForElementIndex(index: number, className: string): void;
Expand Down
6 changes: 0 additions & 6 deletions packages/mdc-list/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,6 @@ export class MDCList extends MDCComponent<MDCListFoundation> {
notifyAction: (index) => {
this.emit<MDCListActionEventDetail>(strings.ACTION_EVENT, {index}, /** shouldBubble */ true);
},
removeAttributeForElementIndex: (index, attr) => {
const element = this.listElements[index];
if (element) {
element.removeAttribute(attr);
}
},
removeClassForElementIndex: (index, className) => {
const element = this.listElements[index];
if (element) {
Expand Down
1 change: 0 additions & 1 deletion packages/mdc-list/foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ export class MDCListFoundation extends MDCFoundation<MDCListAdapter> {
isCheckboxCheckedAtIndex: () => false,
isFocusInsideList: () => false,
notifyAction: () => undefined,
removeAttributeForElementIndex: () => undefined,
removeClassForElementIndex: () => undefined,
setAttributeForElementIndex: () => undefined,
setCheckedCheckboxOrRadioAtIndex: () => undefined,
Expand Down
3 changes: 1 addition & 2 deletions test/unit/mdc-list/foundation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ test('exports cssClasses', () => {
test('defaultAdapter returns a complete adapter implementation', () => {
verifyDefaultAdapter(MDCListFoundation, [
'getListItemCount', 'getFocusedElementIndex', 'setAttributeForElementIndex',
'removeAttributeForElementIndex', 'addClassForElementIndex', 'removeClassForElementIndex',
'addClassForElementIndex', 'removeClassForElementIndex',
'focusItemAtIndex', 'setTabIndexForListItemChildren', 'hasRadioAtIndex',
'hasCheckboxAtIndex', 'isCheckboxCheckedAtIndex', 'setCheckedCheckboxOrRadioAtIndex',
'notifyAction', 'isFocusInsideList',
Expand Down Expand Up @@ -577,7 +577,6 @@ test('#handleKeydown space key is triggered 2x when singleSelection does not un-

td.verify(preventDefault(), {times: 2});
td.verify(mockAdapter.setAttributeForElementIndex(0, strings.ARIA_SELECTED, 'true'), {times: 2});
td.verify(mockAdapter.removeAttributeForElementIndex(0, strings.ARIA_SELECTED), {times: 0});
});

test('#handleKeydown space key is triggered 2x when singleSelection is true on second ' +
Expand Down
20 changes: 0 additions & 20 deletions test/unit/mdc-list/mdc-list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,26 +168,6 @@ test('adapter#setAttributeForElementIndex sets the attribute for the list elemen
document.body.removeChild(root);
});

test('adapter#removeAttributeForElementIndex does nothing if the element at index does not exist', () => {
const {root, component} = setupTest();
document.body.appendChild(root);
const func = () => {
component.getDefaultFoundation().adapter_.removeAttributeForElementIndex(5, 'foo');
};
assert.doesNotThrow(func);
document.body.removeChild(root);
});

test('adapter#removeAttributeForElementIndex sets the attribute for the list element at index specified', () => {
const {root, component} = setupTest();
document.body.appendChild(root);
const selectedNode = root.querySelectorAll('.mdc-list-item')[1];
component.getDefaultFoundation().adapter_.setAttributeForElementIndex(1, 'foo', 'bar');
component.getDefaultFoundation().adapter_.removeAttributeForElementIndex(1, 'foo');
assert.isFalse(selectedNode.hasAttribute('foo'));
document.body.removeChild(root);
});

test('adapter#addClassForElementIndex does nothing if the element at index does not exist', () => {
const {root, component} = setupTest();
document.body.appendChild(root);
Expand Down

0 comments on commit 6b3a419

Please sign in to comment.