babel-plugin-jsx-dom-expressions 0.31.0-beta.9 → 0.31.0

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.
Files changed (2) hide show
  1. package/index.js +11 -7
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -225,15 +225,15 @@ function getConfig(path) {
225
225
  function registerImportMethod(path, name) {
226
226
  const imports =
227
227
  path.scope.getProgramParent().data.imports ||
228
- (path.scope.getProgramParent().data.imports = new Map());
228
+ (path.scope.getProgramParent().data.imports = new Set());
229
+ const identifier = t__namespace.identifier(`_$${name}`);
229
230
  if (!imports.has(name)) {
230
- const identifier = helperModuleImports.addNamed(path, name, getConfig(path).moduleName, {
231
+ helperModuleImports.addNamed(path, name, getConfig(path).moduleName, {
231
232
  nameHint: `_$${name}`
232
233
  });
233
- imports.set(name, identifier);
234
- return identifier;
234
+ imports.add(name);
235
235
  }
236
- return imports.get(name);
236
+ return identifier;
237
237
  }
238
238
 
239
239
  function jsxElementNameToString(node) {
@@ -465,6 +465,10 @@ function transformCondition(path, inline, deep) {
465
465
  return deep ? expr : t__namespace.arrowFunctionExpression([], expr);
466
466
  }
467
467
 
468
+ function escapeBackticks(value) {
469
+ return value.replaceAll("`", "\\`");
470
+ }
471
+
468
472
  function escapeHTML(s, attr) {
469
473
  if (typeof s !== "string") return s;
470
474
  const delim = attr ? '"' : "<";
@@ -1042,7 +1046,7 @@ function transformAttributes$2(path, results) {
1042
1046
  } else {
1043
1047
  !isSVG && (key = key.toLowerCase());
1044
1048
  results.template += ` ${key}`;
1045
- results.template += value ? `="${value.value}"` : "";
1049
+ results.template += value ? `="${escapeBackticks(value.value)}"` : "";
1046
1050
  }
1047
1051
  }
1048
1052
  });
@@ -2541,7 +2545,7 @@ function transformNode(path, info = {}) {
2541
2545
  : trimWhitespace(node.extra.raw);
2542
2546
  if (!text.length) return null;
2543
2547
  const results = {
2544
- template: text,
2548
+ template: config.generate === "dom" ? escapeBackticks(text) : text,
2545
2549
  decl: [],
2546
2550
  exprs: [],
2547
2551
  dynamics: [],
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.31.0-beta.9",
4
+ "version": "0.31.0",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -23,5 +23,5 @@
23
23
  "@babel/types": "^7.16.0",
24
24
  "html-entities": "2.3.2"
25
25
  },
26
- "gitHead": "2c421965e1f194d4ff7fae88ae278c0a50baa161"
26
+ "gitHead": "f6597dac2273ec022b8859ce868f6138b0c2a180"
27
27
  }