Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSX: <svg : path /> parsed incorrectly #1877

Closed
strager opened this issue Dec 22, 2021 · 0 comments
Closed

JSX: <svg : path /> parsed incorrectly #1877

strager opened this issue Dec 22, 2021 · 0 comments

Comments

@strager
Copy link

strager commented Dec 22, 2021

See also a similar bug in TypeScript: microsoft/TypeScript#47219

esbuild rejects the following code:

import React from "react";
export function MyComponent() {
  return <svg : path />;
}
$ npx esbuild hello.jsx --bundle --external:react
✘ [ERROR] Expected ">" but found ":"

    hello.jsx:3:14:
      3 │   return <svg : path />;
        │               ^
        ╵               >

1 error

According to the JSX specification, whitespace is allowed around the : token.

Babel, ESLint, and Flow interpret this code correctly, treating svg:path as the tag's name.

esbuild does parse the following correctly (I think; I haven't fully tested):

import React from "react";
export function MyComponent() {
  return <svg:path />;
}
$ npx esbuild hello.jsx --bundle --external:react
[snip]
  // hello.jsx
  var import_react = __toESM(__require("react"));
  function MyComponent() {
    return /* @__PURE__ */ import_react.default.createElement("svg:path", null);
  }
})();
@evanw evanw closed this as completed in 54f7c63 Dec 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant