babel-plugin-jsx-dom-expressions 0.35.6 → 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 +38 -26
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1838,39 +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)) {
|
|
1855
|
+
expression.body.body = expression.body.body.map(e => {
|
|
1856
|
+
if (t__namespace.isReturnStatement(e))
|
|
1857
|
+
e.argument = escapeExpression(path, e.argument, attr, escapeLiterals);
|
|
1858
|
+
return e;
|
|
1859
|
+
});
|
|
1860
|
+
} else expression.body = escapeExpression(path, expression.body, attr, escapeLiterals);
|
|
1846
1861
|
return expression;
|
|
1847
1862
|
} else if (t__namespace.isTemplateLiteral(expression)) {
|
|
1848
|
-
expression.expressions = expression.expressions.map(e =>
|
|
1863
|
+
expression.expressions = expression.expressions.map(e =>
|
|
1864
|
+
escapeExpression(path, e, attr, escapeLiterals)
|
|
1865
|
+
);
|
|
1849
1866
|
return expression;
|
|
1850
1867
|
} else if (t__namespace.isUnaryExpression(expression)) {
|
|
1851
|
-
expression.argument = escapeExpression(path, expression.argument, attr);
|
|
1852
1868
|
return expression;
|
|
1853
1869
|
} else if (t__namespace.isBinaryExpression(expression)) {
|
|
1854
|
-
expression.left = escapeExpression(path, expression.left, attr);
|
|
1855
|
-
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);
|
|
1856
1872
|
return expression;
|
|
1857
1873
|
} else if (t__namespace.isConditionalExpression(expression)) {
|
|
1858
|
-
expression.consequent = escapeExpression(path, expression.consequent, attr);
|
|
1859
|
-
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);
|
|
1860
1876
|
return expression;
|
|
1861
1877
|
} else if (t__namespace.isLogicalExpression(expression)) {
|
|
1862
|
-
expression.right = escapeExpression(path, expression.right, attr);
|
|
1878
|
+
expression.right = escapeExpression(path, expression.right, attr, escapeLiterals);
|
|
1863
1879
|
if (expression.operator !== "&&") {
|
|
1864
|
-
expression.left = escapeExpression(path, expression.left, attr);
|
|
1880
|
+
expression.left = escapeExpression(path, expression.left, attr, escapeLiterals);
|
|
1865
1881
|
}
|
|
1866
1882
|
return expression;
|
|
1867
1883
|
} else if (t__namespace.isCallExpression(expression) && t__namespace.isFunction(expression.callee)) {
|
|
1868
1884
|
if (t__namespace.isBlockStatement(expression.callee.body)) {
|
|
1869
1885
|
expression.callee.body.body = expression.callee.body.body.map(e => {
|
|
1870
|
-
if (t__namespace.isReturnStatement(e))
|
|
1886
|
+
if (t__namespace.isReturnStatement(e))
|
|
1887
|
+
e.argument = escapeExpression(path, e.argument, attr, escapeLiterals);
|
|
1871
1888
|
return e;
|
|
1872
1889
|
});
|
|
1873
|
-
} else
|
|
1890
|
+
} else
|
|
1891
|
+
expression.callee.body = escapeExpression(path, expression.callee.body, attr, escapeLiterals);
|
|
1874
1892
|
return expression;
|
|
1875
1893
|
}
|
|
1876
1894
|
|
|
@@ -2035,16 +2053,7 @@ function transformAttributes$1(path, results, info) {
|
|
|
2035
2053
|
t__namespace.stringLiteral(
|
|
2036
2054
|
(i ? ";" : "") + (t__namespace.isIdentifier(p.key) ? p.key.name : p.key.value) + ":"
|
|
2037
2055
|
),
|
|
2038
|
-
|
|
2039
|
-
? t__namespace.stringLiteral(escapeHTML(p.value.value))
|
|
2040
|
-
: t__namespace.isNumericLiteral(p.value)
|
|
2041
|
-
? p.value
|
|
2042
|
-
: t__namespace.isTemplateLiteral(p.value) && p.value.expressions.length === 0
|
|
2043
|
-
? t__namespace.stringLiteral(escapeHTML(p.value.quasis[0].value.raw))
|
|
2044
|
-
: t__namespace.callExpression(registerImportMethod(path, "escape"), [
|
|
2045
|
-
p.value,
|
|
2046
|
-
t__namespace.booleanLiteral(true)
|
|
2047
|
-
])
|
|
2056
|
+
escapeExpression(path, p.value, true, true)
|
|
2048
2057
|
)
|
|
2049
2058
|
);
|
|
2050
2059
|
let res = props[0];
|
|
@@ -2196,10 +2205,13 @@ function createElement(path, { topLevel, hydratable }) {
|
|
|
2196
2205
|
if (v.length) memo.push(t__namespace.stringLiteral(v));
|
|
2197
2206
|
} else {
|
|
2198
2207
|
const child = transformNode(path);
|
|
2199
|
-
if (markers && child.exprs.length && !child.spreadElement)
|
|
2200
|
-
|
|
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]);
|
|
2201
2212
|
memo.push(getCreateTemplate(config, path, child)(path, child, true));
|
|
2202
|
-
if (markers && child.exprs.length && !child.spreadElement)
|
|
2213
|
+
if (markers && child.exprs.length && !child.spreadElement)
|
|
2214
|
+
memo.push(t__namespace.stringLiteral("<!--/-->"));
|
|
2203
2215
|
}
|
|
2204
2216
|
return memo;
|
|
2205
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
|
}
|