babel-plugin-jsx-dom-expressions 0.37.0-beta.0 → 0.37.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +39 -2
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1068,6 +1068,8 @@ function transformAttributes$2(path, results) {
|
|
|
1068
1068
|
attributes.map(a => a.node)
|
|
1069
1069
|
);
|
|
1070
1070
|
|
|
1071
|
+
let needsSpacing = true;
|
|
1072
|
+
|
|
1071
1073
|
path
|
|
1072
1074
|
.get("openingElement")
|
|
1073
1075
|
.get("attributes")
|
|
@@ -1365,16 +1367,51 @@ function transformAttributes$2(path, results) {
|
|
|
1365
1367
|
);
|
|
1366
1368
|
} else {
|
|
1367
1369
|
!isSVG && (key = key.toLowerCase());
|
|
1368
|
-
results.template +=
|
|
1370
|
+
results.template += `${needsSpacing ? ' ' : ''}${key}`;
|
|
1369
1371
|
if (!value) return;
|
|
1372
|
+
|
|
1370
1373
|
let text = value.value;
|
|
1374
|
+
let needsQuoting = false;
|
|
1375
|
+
|
|
1371
1376
|
if (key === "style" || key === "class") {
|
|
1372
1377
|
text = trimWhitespace(text);
|
|
1373
1378
|
if (key === "style") {
|
|
1374
1379
|
text = text.replace(/; /g, ";").replace(/: /g, ":");
|
|
1375
1380
|
}
|
|
1376
1381
|
}
|
|
1377
|
-
|
|
1382
|
+
|
|
1383
|
+
if (!text.length) {
|
|
1384
|
+
results.template += `=""`;
|
|
1385
|
+
return;
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
for (let i = 0, len = text.length; i < len; i++) {
|
|
1389
|
+
let char = text[i];
|
|
1390
|
+
|
|
1391
|
+
if (
|
|
1392
|
+
char === "'" ||
|
|
1393
|
+
char === '"' ||
|
|
1394
|
+
char === " " ||
|
|
1395
|
+
char === "\t" ||
|
|
1396
|
+
char === "\n" ||
|
|
1397
|
+
char === "\r" ||
|
|
1398
|
+
char === "`" ||
|
|
1399
|
+
char === "=" ||
|
|
1400
|
+
char === "<" ||
|
|
1401
|
+
char === ">"
|
|
1402
|
+
) {
|
|
1403
|
+
needsQuoting = true;
|
|
1404
|
+
}
|
|
1405
|
+
}
|
|
1406
|
+
|
|
1407
|
+
if (needsQuoting) {
|
|
1408
|
+
|
|
1409
|
+
needsSpacing = false;
|
|
1410
|
+
results.template += `="${escapeBackticks(escapeHTML(text, true))}"`;
|
|
1411
|
+
} else {
|
|
1412
|
+
needsSpacing = true;
|
|
1413
|
+
results.template += `=${escapeBackticks(escapeHTML(text, true))}`;
|
|
1414
|
+
}
|
|
1378
1415
|
}
|
|
1379
1416
|
}
|
|
1380
1417
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "babel-plugin-jsx-dom-expressions",
|
|
3
3
|
"description": "A JSX to DOM plugin that wraps expressions for fine grained change detection",
|
|
4
|
-
"version": "0.37.0-beta.
|
|
4
|
+
"version": "0.37.0-beta.2",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@babel/core": "^7.20.12"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "bc79e4f6f883b6a1f6f1a68482f5720945c6dcc0"
|
|
35
35
|
}
|