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

MDCList notifyAction() emits primitive event detail #4355

@acdvorak

Description

@acdvorak

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions