babel-plugin-jsx-dom-expressions 0.35.8 → 0.35.9
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 +34 -27
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1838,44 +1838,57 @@ function setAttr$1(attribute, results, name, value, isSVG) {
|
|
|
1838
1838
|
}
|
|
1839
1839
|
}
|
|
1840
1840
|
|
|
1841
|
-
function escapeExpression(path, expression, attr) {
|
|
1842
|
-
if (
|
|
1841
|
+
function escapeExpression(path, expression, attr, escapeLiterals) {
|
|
1842
|
+
if (
|
|
1843
|
+
t__namespace.isStringLiteral(expression) ||
|
|
1844
|
+
t__namespace.isNumericLiteral(expression) ||
|
|
1845
|
+
(t__namespace.isTemplateLiteral(expression) && expression.expressions.length === 0)
|
|
1846
|
+
) {
|
|
1847
|
+
if (escapeLiterals) {
|
|
1848
|
+
if (t__namespace.isStringLiteral(expression)) return t__namespace.stringLiteral(escapeHTML(expression.value, attr));
|
|
1849
|
+
else if (t__namespace.isTemplateLiteral(expression))
|
|
1850
|
+
return t__namespace.stringLiteral(escapeHTML(expression.quasis[0].value.raw, attr));
|
|
1851
|
+
}
|
|
1843
1852
|
return expression;
|
|
1844
1853
|
} else if (t__namespace.isFunction(expression)) {
|
|
1845
1854
|
if (t__namespace.isBlockStatement(expression.body)) {
|
|
1846
1855
|
expression.body.body = expression.body.body.map(e => {
|
|
1847
|
-
if (t__namespace.isReturnStatement(e))
|
|
1856
|
+
if (t__namespace.isReturnStatement(e))
|
|
1857
|
+
e.argument = escapeExpression(path, e.argument, attr, escapeLiterals);
|
|
1848
1858
|
return e;
|
|
1849
1859
|
});
|
|
1850
|
-
} else expression.body = escapeExpression(path, expression.body, attr);
|
|
1860
|
+
} else expression.body = escapeExpression(path, expression.body, attr, escapeLiterals);
|
|
1851
1861
|
return expression;
|
|
1852
1862
|
} else if (t__namespace.isTemplateLiteral(expression)) {
|
|
1853
|
-
expression.expressions = expression.expressions.map(e =>
|
|
1863
|
+
expression.expressions = expression.expressions.map(e =>
|
|
1864
|
+
escapeExpression(path, e, attr, escapeLiterals)
|
|
1865
|
+
);
|
|
1854
1866
|
return expression;
|
|
1855
1867
|
} else if (t__namespace.isUnaryExpression(expression)) {
|
|
1856
|
-
expression.argument = escapeExpression(path, expression.argument, attr);
|
|
1857
1868
|
return expression;
|
|
1858
1869
|
} else if (t__namespace.isBinaryExpression(expression)) {
|
|
1859
|
-
expression.left = escapeExpression(path, expression.left, attr);
|
|
1860
|
-
expression.right = escapeExpression(path, expression.right, attr);
|
|
1870
|
+
expression.left = escapeExpression(path, expression.left, attr, escapeLiterals);
|
|
1871
|
+
expression.right = escapeExpression(path, expression.right, attr, escapeLiterals);
|
|
1861
1872
|
return expression;
|
|
1862
1873
|
} else if (t__namespace.isConditionalExpression(expression)) {
|
|
1863
|
-
expression.consequent = escapeExpression(path, expression.consequent, attr);
|
|
1864
|
-
expression.alternate = escapeExpression(path, expression.alternate, attr);
|
|
1874
|
+
expression.consequent = escapeExpression(path, expression.consequent, attr, escapeLiterals);
|
|
1875
|
+
expression.alternate = escapeExpression(path, expression.alternate, attr, escapeLiterals);
|
|
1865
1876
|
return expression;
|
|
1866
1877
|
} else if (t__namespace.isLogicalExpression(expression)) {
|
|
1867
|
-
expression.right = escapeExpression(path, expression.right, attr);
|
|
1878
|
+
expression.right = escapeExpression(path, expression.right, attr, escapeLiterals);
|
|
1868
1879
|
if (expression.operator !== "&&") {
|
|
1869
|
-
expression.left = escapeExpression(path, expression.left, attr);
|
|
1880
|
+
expression.left = escapeExpression(path, expression.left, attr, escapeLiterals);
|
|
1870
1881
|
}
|
|
1871
1882
|
return expression;
|
|
1872
1883
|
} else if (t__namespace.isCallExpression(expression) && t__namespace.isFunction(expression.callee)) {
|
|
1873
1884
|
if (t__namespace.isBlockStatement(expression.callee.body)) {
|
|
1874
1885
|
expression.callee.body.body = expression.callee.body.body.map(e => {
|
|
1875
|
-
if (t__namespace.isReturnStatement(e))
|
|
1886
|
+
if (t__namespace.isReturnStatement(e))
|
|
1887
|
+
e.argument = escapeExpression(path, e.argument, attr, escapeLiterals);
|
|
1876
1888
|
return e;
|
|
1877
1889
|
});
|
|
1878
|
-
} else
|
|
1890
|
+
} else
|
|
1891
|
+
expression.callee.body = escapeExpression(path, expression.callee.body, attr, escapeLiterals);
|
|
1879
1892
|
return expression;
|
|
1880
1893
|
}
|
|
1881
1894
|
|
|
@@ -2040,16 +2053,7 @@ function transformAttributes$1(path, results, info) {
|
|
|
2040
2053
|
t__namespace.stringLiteral(
|
|
2041
2054
|
(i ? ";" : "") + (t__namespace.isIdentifier(p.key) ? p.key.name : p.key.value) + ":"
|
|
2042
2055
|
),
|
|
2043
|
-
|
|
2044
|
-
? t__namespace.stringLiteral(escapeHTML(p.value.value))
|
|
2045
|
-
: t__namespace.isNumericLiteral(p.value)
|
|
2046
|
-
? p.value
|
|
2047
|
-
: t__namespace.isTemplateLiteral(p.value) && p.value.expressions.length === 0
|
|
2048
|
-
? t__namespace.stringLiteral(escapeHTML(p.value.quasis[0].value.raw))
|
|
2049
|
-
: t__namespace.callExpression(registerImportMethod(path, "escape"), [
|
|
2050
|
-
p.value,
|
|
2051
|
-
t__namespace.booleanLiteral(true)
|
|
2052
|
-
])
|
|
2056
|
+
escapeExpression(path, p.value, true, true)
|
|
2053
2057
|
)
|
|
2054
2058
|
);
|
|
2055
2059
|
let res = props[0];
|
|
@@ -2201,10 +2205,13 @@ function createElement(path, { topLevel, hydratable }) {
|
|
|
2201
2205
|
if (v.length) memo.push(t__namespace.stringLiteral(v));
|
|
2202
2206
|
} else {
|
|
2203
2207
|
const child = transformNode(path);
|
|
2204
|
-
if (markers && child.exprs.length && !child.spreadElement)
|
|
2205
|
-
|
|
2208
|
+
if (markers && child.exprs.length && !child.spreadElement)
|
|
2209
|
+
memo.push(t__namespace.stringLiteral("<!--#-->"));
|
|
2210
|
+
if (child.exprs.length && !child.spreadElement)
|
|
2211
|
+
child.exprs[0] = escapeExpression(path, child.exprs[0]);
|
|
2206
2212
|
memo.push(getCreateTemplate(config, path, child)(path, child, true));
|
|
2207
|
-
if (markers && child.exprs.length && !child.spreadElement)
|
|
2213
|
+
if (markers && child.exprs.length && !child.spreadElement)
|
|
2214
|
+
memo.push(t__namespace.stringLiteral("<!--/-->"));
|
|
2208
2215
|
}
|
|
2209
2216
|
return memo;
|
|
2210
2217
|
}, []);
|
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.35.
|
|
4
|
+
"version": "0.35.9",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"@babel/core": "^7.0.0"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "c0e2bc4bf3ce42c2a266529d43fad1d1e4a651f5"
|
|
31
31
|
}
|