babel-plugin-jsx-dom-expressions 0.31.0-beta.6 → 0.31.4

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 +16 -14
  2. package/package.json +5 -5
package/index.js CHANGED
@@ -16,14 +16,12 @@ function _interopNamespace(e) {
16
16
  var d = Object.getOwnPropertyDescriptor(e, k);
17
17
  Object.defineProperty(n, k, d.get ? d : {
18
18
  enumerable: true,
19
- get: function () {
20
- return e[k];
21
- }
19
+ get: function () { return e[k]; }
22
20
  });
23
21
  }
24
22
  });
25
23
  }
26
- n['default'] = e;
24
+ n["default"] = e;
27
25
  return Object.freeze(n);
28
26
  }
29
27
 
@@ -227,15 +225,15 @@ function getConfig(path) {
227
225
  function registerImportMethod(path, name) {
228
226
  const imports =
229
227
  path.scope.getProgramParent().data.imports ||
230
- (path.scope.getProgramParent().data.imports = new Map());
228
+ (path.scope.getProgramParent().data.imports = new Set());
229
+ const identifier = t__namespace.identifier(`_$${name}`);
231
230
  if (!imports.has(name)) {
232
- const identifier = helperModuleImports.addNamed(path, name, getConfig(path).moduleName, {
231
+ helperModuleImports.addNamed(path, name, getConfig(path).moduleName, {
233
232
  nameHint: `_$${name}`
234
233
  });
235
- imports.set(name, identifier);
236
- return identifier;
234
+ imports.add(name);
237
235
  }
238
- return imports.get(name);
236
+ return identifier;
239
237
  }
240
238
 
241
239
  function jsxElementNameToString(node) {
@@ -467,6 +465,10 @@ function transformCondition(path, inline, deep) {
467
465
  return deep ? expr : t__namespace.arrowFunctionExpression([], expr);
468
466
  }
469
467
 
468
+ function escapeBackticks(value) {
469
+ return value.replace(/`/g, "\\`");
470
+ }
471
+
470
472
  function escapeHTML(s, attr) {
471
473
  if (typeof s !== "string") return s;
472
474
  const delim = attr ? '"' : "<";
@@ -1044,7 +1046,7 @@ function transformAttributes$2(path, results) {
1044
1046
  } else {
1045
1047
  !isSVG && (key = key.toLowerCase());
1046
1048
  results.template += ` ${key}`;
1047
- results.template += value ? `="${value.value}"` : "";
1049
+ results.template += value ? `="${escapeBackticks(value.value)}"` : "";
1048
1050
  }
1049
1051
  }
1050
1052
  });
@@ -2543,7 +2545,7 @@ function transformNode(path, info = {}) {
2543
2545
  : trimWhitespace(node.extra.raw);
2544
2546
  if (!text.length) return null;
2545
2547
  const results = {
2546
- template: text,
2548
+ template: config.generate === "dom" ? escapeBackticks(text) : text,
2547
2549
  decl: [],
2548
2550
  exprs: [],
2549
2551
  dynamics: [],
@@ -2643,8 +2645,8 @@ var config = {
2643
2645
  };
2644
2646
 
2645
2647
  var preprocess = (path, { opts }) => {
2646
- path.hub.file.metadata.config = Object.assign({}, config, opts);
2647
- const lib = config.requireImportSource;
2648
+ const merged = path.hub.file.metadata.config = Object.assign({}, config, opts);
2649
+ const lib = merged.requireImportSource;
2648
2650
  if (lib) {
2649
2651
  const comments = path.hub.file.ast.comments;
2650
2652
  for(let i = 0; i < comments.length; i++) {
@@ -2659,7 +2661,7 @@ var preprocess = (path, { opts }) => {
2659
2661
  var index = () => {
2660
2662
  return {
2661
2663
  name: "JSX DOM Expressions",
2662
- inherits: SyntaxJSX__default['default'],
2664
+ inherits: SyntaxJSX__default["default"],
2663
2665
  visitor: {
2664
2666
  JSXElement: transformJSX,
2665
2667
  JSXFragment: transformJSX,
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.6",
4
+ "version": "0.31.4",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -18,10 +18,10 @@
18
18
  "prepublishOnly": "npm run build"
19
19
  },
20
20
  "dependencies": {
21
- "@babel/helper-module-imports": "^7.10.4",
22
- "@babel/plugin-syntax-jsx": "^7.10.4",
23
- "@babel/types": "^7.11.5",
21
+ "@babel/helper-module-imports": "7.16.0",
22
+ "@babel/plugin-syntax-jsx": "^7.16.5",
23
+ "@babel/types": "^7.16.0",
24
24
  "html-entities": "2.3.2"
25
25
  },
26
- "gitHead": "eb9258c44a11aae76b5498549f1dd32645bb6b01"
26
+ "gitHead": "411215d16c3bf06ced1b55ab76fc85108d053f98"
27
27
  }