Merge pull request #6287 from RyanCavanaugh/fix6241

Escape quotes when they appear as HTML entities in JSX text
This commit is contained in:
Ryan Cavanaugh 2016-01-01 09:31:13 -08:00
commit 6be0206242
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]);
const 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>;