Comparing version 1.1.2 to 1.1.3
@@ -53,3 +53,3 @@ "use strict"; | ||
else { | ||
copyToken(); | ||
processStringPropValue(); | ||
} | ||
@@ -73,2 +73,8 @@ } | ||
} | ||
function processStringPropValue() { | ||
var value = tokens[tokenIndex].value; | ||
var replacementCode = formatJSXTextReplacement(value); | ||
var literalCode = formatJSXStringValueLiteral(value); | ||
replaceToken(literalCode + replacementCode); | ||
} | ||
/** | ||
@@ -123,11 +129,3 @@ * Process the first part of a tag, before any props. | ||
else if (matches(['jsxText'])) { | ||
var value = tokens[tokenIndex].value; | ||
var replacementCode = formatJSXTextReplacement(value); | ||
var literalCode = formatJSXTextLiteral(value); | ||
if (literalCode === '""') { | ||
replaceToken(replacementCode); | ||
} | ||
else { | ||
replaceToken(', ' + literalCode + replacementCode); | ||
} | ||
processChildTextElement(); | ||
} | ||
@@ -139,2 +137,13 @@ else { | ||
} | ||
function processChildTextElement() { | ||
var value = tokens[tokenIndex].value; | ||
var replacementCode = formatJSXTextReplacement(value); | ||
var literalCode = formatJSXTextLiteral(value); | ||
if (literalCode === '""') { | ||
replaceToken(replacementCode); | ||
} | ||
else { | ||
replaceToken(', ' + literalCode + replacementCode); | ||
} | ||
} | ||
function processJSXTag() { | ||
@@ -230,1 +239,10 @@ // First tag is always jsxTagStart. | ||
} | ||
/** | ||
* Format a string in the value position of a JSX prop. | ||
* | ||
* Use the same implementation as convertAttribute from | ||
* babel-helper-builder-react-jsx. | ||
*/ | ||
function formatJSXStringValueLiteral(text) { | ||
return JSON.stringify(text.replace(/\n\s+/g, " ")); | ||
} |
{ | ||
"name": "sucrase", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "Super-fast alternative to Babel for when you can target modern JS runtimes", | ||
@@ -5,0 +5,0 @@ "author": "Alan Pierce <alangpierce@gmail.com>", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25224
560