Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MDCList notifyAction() emits primitive event detail #4355

Closed
acdvorak opened this issue Feb 5, 2019 · 0 comments
Closed

MDCList notifyAction() emits primitive event detail #4355

acdvorak opened this issue Feb 5, 2019 · 0 comments

Comments

@acdvorak
Copy link
Contributor

acdvorak commented Feb 5, 2019

Problem

We're currently emitting a number value for the CustomEvent.detail property in
MDCListAdapter.notifyAction():

notifyAction: (index) => {
this.emit(strings.ACTION_EVENT, index, /** shouldBubble */ true);
},

This is technically allowed by TypeScript's CustomEvent<T> interface:

https://github.com/Microsoft/TypeScript/blob/2f9218f346bbc606cccc4aebfca1c2c4f3167fee/lib/lib.dom.d.ts#L3415-L3422

interface CustomEvent<T = any> extends Event {
    /**
     * Returns any custom data event was created with.
     * Typically used for synthetic events.
     */
    readonly detail: T;
    initCustomEvent(typeArg: string, canBubbleArg: boolean, cancelableArg: boolean, detailArg: T): void;
}

However, emitting a primitive value for an event detail is not future-resistant. If we ever need to pass more data, we'll be forced to break backward compatibility for a large number of customers.

Solution

Rather than break backward compatibility later—after lots of downstream consumers have already wrapped the new v0.44.0 MDCList API from PR #4144—we should break it now.

This will also simplify PR #4334 and PR #4342.

acdvorak added a commit that referenced this issue Feb 5, 2019
Fixes #4355

BREAKING CHANGE: The default `MDCListAdapter.notifyAction()` implementation now emits an object of type `{index: number}` rather than a primitive `number` directly.
acdvorak added a commit that referenced this issue Feb 5, 2019
Fixes #4355

BREAKING CHANGE: The default `MDCListAdapter.notifyAction()` implementation now emits an object of type `{index: number}` rather than a primitive `number` directly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant