Skip to content

JSX attribute key ignores special characters for wrapping as string #5634

@idoros

Description

@idoros
var x = <div xx-y="val"></div>;
var y = <div x-y="val"></div>;
var z = <div longattrr="val"></div>;

is transpiled to:

var x = React.createElement("div", {"xx-y": "val"});
var y = React.createElement("div", {x-y: "val"}); // SYNTAX ERROR 
var z = React.createElement("div", {"longattrr": "val"});

It seems typescript decides to wrap option keys as string only by the length of the attribute key (4 characters) and not by the characters that might break javascript.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFixedA PR has been merged for this issue

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions