From 99b260670b18676b7ba9af3b03d1d0821a7ddde2 Mon Sep 17 00:00:00 2001 From: Evan Wallace Date: Wed, 7 Apr 2021 03:01:22 -0700 Subject: [PATCH] fix #1115: add a special-cased error message --- CHANGELOG.md | 36 +++++++++++++++++++++++ internal/js_lexer/js_lexer.go | 12 ++++++++ internal/js_parser/js_parser.go | 51 ++++++++++++++++++++++++++++++++- scripts/end-to-end-tests.js | 38 ++++++++++++++++++++++++ 4 files changed, 136 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index df1a51fc347..cad8e0f1fb0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,42 @@ Starting with this release, esbuild will now allow `node_modules` directories to take precedence over `NODE_PATH` directories. This is a deviation from the published algorithm. +* Provide a better error message for incorrectly-quoted JSX attributes ([959](https://github.com/evanw/esbuild/issues/959), [#1115](https://github.com/evanw/esbuild/issues/1115)) + + People sometimes try to use the output of `JSON.stringify()` as a JSX attribute when automatically-generating JSX code. Doing so is incorrect because JSX strings work like XML instead of like JS (since JSX is XML-in-JS). Specifically, using a backslash before a quote does not cause it to be escaped: + + ``` + JSX ends the "content" attribute here and sets "content" to 'some so-called \\' + v + let button =