Skip to content

Proposal Urgent: computed member expression for the opening tag names of which the property contains a hypen #163

@talatkuyuk

Description

@talatkuyuk

An opening tag name could contain a hypen - in web components. JSX support it as well as a valid jsx identifier.

<custom-tag />

An opening tag name can be a MemberExpression with dot notation like:

<MyComponents.Comment />

And, (Proposal) the bracket notation of member expression should be supported as well,

<MyComponents["Comment"] />

Why do I need this? This is because, a member expression should support for property which contains hypen:

<MyComponents.custom-tag />

But, the property custom-tag is not valid js identifier, it must be called with bracket notation.

<MyComponents["custom-tag"] />

In order to achieve this, just we need a property called computed in the interface JSXMemberExpression as the same mentality as the type of MemberExpression of estree. If computed is true, property can be a Literal as well.

interface JSXMemberExpression <: Expression {
    type: "JSXMemberExpression";
    object: JSXMemberExpression | JSXIdentifier;
-   property: JSXIdentifier;
+   property: JSXIdentifier | Literal;
+   computed: boolean;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    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