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

Commit

Permalink
Project import generated by Copybara.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 291768975
  • Loading branch information
material-web-copybara authored and abhiomkar committed Jan 27, 2020
1 parent c6953e5 commit b953810
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 19 deletions.
6 changes: 3 additions & 3 deletions packages/mdc-data-table/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ CSS Class | Description
`mdc-data-table` | Mandatory. The root DOM element containing `table` and other supporting elements.
`mdc-data-table__table` | Mandatory. Table element. Added to `table` HTML tag.
`mdc-data-table__header-row` | Mandatory. Table header row element. Added to `thead > tr` HTML tag.
`mdc-data-table__header-cell` | Mandatory. Table header cell element. Added to `thead > tr > th` HTML tag.
`mdc-data-table__header-cell--checkbox` | Optional. Table header cell element that contains `mdc-checkbox`. Added to `thead > tr > th` HTML tag.
`mdc-data-table__header-cell--numeric` | Optional. Table header cell element that maps to numeric cells. Added to `thead > tr > th` HTML tag.
`mdc-data-table__header-cell` | Mandatory. Table header cell element. Added to `thead > th > td` HTML tag.
`mdc-data-table__header-cell--checkbox` | Optional. Table header cell element that contains `mdc-checkbox`. Added to `thead> th > td:first-child` HTML tag.
`mdc-data-table__header-cell--numeric` | Optional. Table header cell element that maps to numeric cells. Added to `thead > th > td` HTML tag.
`mdc-data-table__content` | Mandatory. Table body element. Added to `tbody` HTML tag.
`mdc-data-table__row` | Mandatory. Table row element. Added to `tbody > tr` HTML tag.
`mdc-data-table__cell` | Mandatory. Table cell element. Added to `tbody > tr > td` HTML tag.
Expand Down
3 changes: 3 additions & 0 deletions packages/mdc-icon-button/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ Then instantiate an `MDCIconButtonToggle` on the root element.
<button id="add-to-favorites"
class="mdc-icon-button"
aria-label="Add to favorites"
aria-hidden="true"
aria-pressed="false">
<i class="material-icons mdc-icon-button__icon mdc-icon-button__icon--on">favorite</i>
<i class="material-icons mdc-icon-button__icon">favorite_border</i>
Expand All @@ -98,6 +99,7 @@ The icon button toggle can be used with SVGs.
<button id="star-this-item"
class="mdc-icon-button mdc-icon-button--on"
aria-label="Unstar this item"
aria-hidden="true"
aria-pressed="true">
<svg class="mdc-icon-button__icon">
...
Expand All @@ -116,6 +118,7 @@ The icon button toggle can be used with `img` tags.
<button id="star-this-item"
class="mdc-icon-button mdc-icon-button--on"
aria-label="Unstar this item"
aria-hidden="true"
aria-pressed="true">
<img src="" class="mdc-icon-button__icon"/>
<img src="" class="mdc-icon-button__icon mdc-icon-button__icon--on"/>
Expand Down
5 changes: 0 additions & 5 deletions packages/mdc-textfield/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1143,11 +1143,6 @@
@include rtl-mixins.reflexive-property(padding, variables.$input-padding, icon-variables.$icon-padding);
}
}

// Outlined uses 16px for text alignment when using a trailing icon.
&.mdc-text-field--outlined {
@include icon-mixins.trailing-icon-horizontal-position_(icon-variables.$icon-position, $query: $query);
}
}

@mixin dense-with-trailing-icon_($query: feature-targeting-functions.all()) {
Expand Down
42 changes: 31 additions & 11 deletions testing/helpers/foundation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,35 @@ export interface FoundationConstructor<F extends MDCFoundation> extends
new(...args: any[]): F;
}

/**
* @returns Method names of the given foundation class, including all MDC
* superclasses.
*/
function getFoundationMethods<F extends MDCFoundation>(
// tslint:disable-next-line:enforce-name-casing
FoundationCtor: FoundationConstructor<F>,
foundationMethods = []): string[] {
const methods = foundationMethods.concat(
[].slice.call(Object.getOwnPropertyNames(FoundationCtor.prototype)));
// tslint:disable-next-line:enforce-name-casing
const BaseFoundationCtor = Object.getPrototypeOf(FoundationCtor);
if (BaseFoundationCtor.toString().match(/MDC/)) {
return getFoundationMethods(BaseFoundationCtor, methods);
} else {
return methods;
}
}

/**
* Creates a mockFoundation object with spy functions for each of the
* foundation class' methods.
*/
export function createMockFoundation<F extends MDCFoundation>(
FoundationClass: FoundationConstructor<F>) {
const mockFoundationMethods =
Object.getOwnPropertyNames(FoundationClass.prototype)
.concat(Object.getOwnPropertyNames(MDCFoundation.prototype));
// tslint:disable-next-line:enforce-name-casing
FoundationCtor: FoundationConstructor<F>) {
const mockFoundationMethods = getFoundationMethods(FoundationCtor);
const mockFoundation =
jasmine.createSpyObj(FoundationClass.name, mockFoundationMethods);
jasmine.createSpyObj(FoundationCtor.name, mockFoundationMethods);
return mockFoundation;
}

Expand All @@ -51,15 +69,16 @@ export function createMockFoundation<F extends MDCFoundation>(
* adapter class' methods.
*/
export function createMockAdapter<F extends MDCFoundation>(
FoundationClass: FoundationConstructor<F>) {
// tslint:disable-next-line:enforce-name-casing
FoundationCtor: FoundationConstructor<F>) {
const mockAdapterMethods = {};
Object.keys(FoundationClass.defaultAdapter).forEach((methodName) => {
const value = (FoundationClass.defaultAdapter as any)[methodName];
Object.keys(FoundationCtor.defaultAdapter).forEach((methodName) => {
const value = (FoundationCtor.defaultAdapter as any)[methodName];
(mockAdapterMethods as any)[methodName] =
typeof value === 'function' ? value() : value;
});
const mockAdapter =
jasmine.createSpyObj(FoundationClass.name, mockAdapterMethods);
jasmine.createSpyObj(FoundationCtor.name, mockAdapterMethods);
return mockAdapter;
}

Expand All @@ -71,8 +90,9 @@ export function createMockAdapter<F extends MDCFoundation>(
* Every foundation test suite includes this verification.
*/
export function verifyDefaultAdapter<F extends MDCFoundation>(
FoundationClass: FoundationConstructor<F>, expectedMethodNames: string[]) {
const defaultAdapter = FoundationClass.defaultAdapter as {
// tslint:disable-next-line:enforce-name-casing
FoundationCtor: FoundationConstructor<F>, expectedMethodNames: string[]) {
const defaultAdapter = FoundationCtor.defaultAdapter as {
[key: string]: any;
};
const adapterKeys = Object.keys(defaultAdapter);
Expand Down

0 comments on commit b953810

Please sign in to comment.