diff --git a/src/js_lexer.zig b/src/js_lexer.zig index 12ba744ee1..b0f40e5d02 100644 --- a/src/js_lexer.zig +++ b/src/js_lexer.zig @@ -2335,7 +2335,7 @@ fn NewLexer_( lexer.step(); if (isIdentifierStart(lexer.code_point)) { - while (isIdentifierStart(lexer.code_point) or lexer.code_point == '-') { + while (isIdentifierContinue(lexer.code_point) or lexer.code_point == '-') { lexer.step(); } } else { diff --git a/test/cli/run/jsx-namespaced-attributes.test.ts b/test/cli/run/jsx-namespaced-attributes.test.ts new file mode 100644 index 0000000000..5143c06ca2 --- /dev/null +++ b/test/cli/run/jsx-namespaced-attributes.test.ts @@ -0,0 +1,10 @@ +import { expect, it } from "bun:test"; +import { nsExample1, nsExample2, nsExample3, nsExample4 } from "../../snippets/jsx-attributes.tsx"; + +it("parses namespaced attributes correctly", () => { + expect(nsExample1.props).toEqual({ "ns:bar": "baz", "tag": true }); + expect(nsExample2.props).toEqual({ "ns:bar42": "baz", "tag": false }); + expect(nsExample3.props).toEqual({ "ns:bar42bar": "baz" }); + expect(nsExample4.props).toEqual({ "ns42:bar": "baz" }); +}); + diff --git a/test/snippets/jsx-attributes.tsx b/test/snippets/jsx-attributes.tsx new file mode 100644 index 0000000000..f7e43ad611 --- /dev/null +++ b/test/snippets/jsx-attributes.tsx @@ -0,0 +1,47 @@ +// @ts-nocheck + +// Declare a minimally reproducible JSX namespace for testing; +// ensures that no dependencies are required for this test. +export interface JSXIntrinsicElements { + "ns:foo": { + "tag"?: boolean; + "ns:bar"?: string; + "ns:bar42"?: string; + "ns:bar42bar"?: string; + "ns42:bar"?: string; + }; +} + +// Minimal JSX element implementation. +export class Element { + constructor( + public readonly tag: T, + public readonly props: P, + public readonly children: C, + ) { } +} + +export interface JsxElement extends Element { } + +// JSX factory function used when compiling JSX with `jsx` pragma. +// This is what the JSX transpiles to. +export function jsx( + tag: T, + props: P, + ...children: C +) { + return new Element(tag, props, children); +} + +// Define the JSX namespace itself so TypeScript can resolve JSX +// types correctly. +export namespace jsx.JSX { + export interface Element extends JsxElement { } + export type IntrinsicElements = JSXIntrinsicElements; +} + +// Examples of namespaced JSX attributes +export const nsExample1 = ; +export const nsExample2 = ; +export const nsExample3 = ; +export const nsExample4 = ;