Escape quotes when they appear as HTML entities in JSX text

Fixes #6241
This commit is contained in:
Ryan Cavanaugh 2015-12-29 12:39:27 -08:00
parent 72bb1d3dec
commit e12855bca0
5 changed files with 15 additions and 1 deletions

View file

@ -7221,7 +7221,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
// Replace entities like  
result = result.replace(/&(\w+);/g, function(s: any, m: string) {
if (entities[m] !== undefined) {
return String.fromCharCode(entities[m]);
let ch = String.fromCharCode(entities[m]);
// " needs to be escaped
return ch === '"' ? '\\"' : ch;
}
else {
return s;

View file

@ -8,7 +8,9 @@ declare module JSX {
declare var React: any;
<div>Dot goes here: &middot; &notAnEntity; </div>;
<div>Be careful of &quot;-ed strings!</div>;
//// [file.js]
React.createElement("div", null, "Dot goes here: · &notAnEntity; ");
React.createElement("div", null, "Be careful of \"-ed strings!");

View file

@ -19,3 +19,7 @@ declare var React: any;
>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22))
>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22))
<div>Be careful of &quot;-ed strings!</div>;
>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22))
>div : Symbol(JSX.IntrinsicElements, Decl(file.tsx, 1, 22))

View file

@ -20,3 +20,8 @@ declare var React: any;
>div : any
>div : any
<div>Be careful of &quot;-ed strings!</div>;
><div>Be careful of &quot;-ed strings!</div> : JSX.Element
>div : any
>div : any

View file

@ -9,3 +9,4 @@ declare module JSX {
declare var React: any;
<div>Dot goes here: &middot; &notAnEntity; </div>;
<div>Be careful of &quot;-ed strings!</div>;