Skip to content

Add commands array to CustomElementDeclaration #144

Description

@jpzwarte

With https://developer.mozilla.org/en-US/docs/Web/API/Invoker_Commands_API being available in all browsers, we are able to define custom commands for custom elements. However, the custom-elements-manifest schema currently has no support for storing such information.

For example you could have a command jsdoc like this:

/**
 * @command --show-modal - Calls `showModal()` on the `<dialog>` element when invoked.
 */
export class Dialog extends LitElement { ... }

To be able to store this information in custom-elements.json, a schema change is necessary.

I propose adding the following property to the CustomElementDeclaration:

"commands": {
    "description": "The commands that this element will respond to.",
    "items": {
        "$ref": "#/definitions/Command"
    },
    "type": "array"
}

with the following being the Command definition:

"Command": {
    "properties": {
        "description": {
            "description": "A markdown description what the command does when invoked.",
            "type": "string"
        },
        "inheritedFrom": {
            "$ref": "#/definitions/Reference"
        },
        "name": {
            "type": "string"
        }
    },
    "required": [
        "name"
    ],
    "type": "object"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions