babel-plugin-jsx-dom-expressions 0.35.16 → 0.36.0-beta.1

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 +12 -7
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  var SyntaxJSX = require('@babel/plugin-syntax-jsx');
4
4
  var t = require('@babel/types');
5
- var helperModuleImports = require('@babel/helper-module-imports');
6
5
  var htmlEntities = require('html-entities');
6
+ var helperModuleImports = require('@babel/helper-module-imports');
7
7
 
8
8
  function _interopNamespaceDefault(e) {
9
9
  var n = Object.create(null);
@@ -1181,7 +1181,7 @@ function transformAttributes$2(path, results) {
1181
1181
  } else {
1182
1182
  !isSVG && (key = key.toLowerCase());
1183
1183
  results.template += ` ${key}`;
1184
- results.template += value ? `="${escapeBackticks(escapeHTML(value.value, true))}"` : "";
1184
+ results.template += value ? `="${escapeBackticks(escapeHTML(htmlEntities.decode(value.value), true))}"` : "";
1185
1185
  }
1186
1186
  }
1187
1187
  });
@@ -2126,7 +2126,7 @@ function transformAttributes$1(path, results, info) {
2126
2126
  if (t__namespace.isJSXExpressionContainer(value)) value = value.expression;
2127
2127
  key = toAttribute(key, isSVG);
2128
2128
  appendToTemplate(results.template, ` ${key}`);
2129
- appendToTemplate(results.template, value ? `="${escapeHTML(value.value, true)}"` : "");
2129
+ appendToTemplate(results.template, value ? `="${escapeHTML(htmlEntities.decode(value.value), true)}"` : "");
2130
2130
  }
2131
2131
  });
2132
2132
  if (!hasChildren && children) {
@@ -3032,11 +3032,15 @@ function transformComponentChildren(children, config) {
3032
3032
  const filteredChildren = filterChildren(children);
3033
3033
  if (!filteredChildren.length) return;
3034
3034
  let dynamic = false;
3035
+ let pathNodes = [];
3035
3036
 
3036
3037
  let transformedChildren = filteredChildren.reduce((memo, path) => {
3037
3038
  if (t__namespace.isJSXText(path.node)) {
3038
3039
  const v = htmlEntities.decode(trimWhitespace(path.node.extra.raw));
3039
- if (v.length) memo.push(t__namespace.stringLiteral(v));
3040
+ if (v.length) {
3041
+ pathNodes.push(path.node);
3042
+ memo.push(t__namespace.stringLiteral(v));
3043
+ }
3040
3044
  } else {
3041
3045
  const child = transformNode(path, {
3042
3046
  topLevel: true,
@@ -3051,6 +3055,7 @@ function transformComponentChildren(children, config) {
3051
3055
  ) {
3052
3056
  child.exprs[0] = child.exprs[0].body;
3053
3057
  }
3058
+ pathNodes.push(path.node);
3054
3059
  memo.push(getCreateTemplate(config, path, child)(path, child, filteredChildren.length > 1));
3055
3060
  }
3056
3061
  return memo;
@@ -3059,9 +3064,9 @@ function transformComponentChildren(children, config) {
3059
3064
  if (transformedChildren.length === 1) {
3060
3065
  transformedChildren = transformedChildren[0];
3061
3066
  if (
3062
- !t__namespace.isJSXExpressionContainer(filteredChildren[0]) &&
3063
- !t__namespace.isJSXSpreadChild(filteredChildren[0]) &&
3064
- !t__namespace.isJSXText(filteredChildren[0])
3067
+ !t__namespace.isJSXExpressionContainer(pathNodes[0]) &&
3068
+ !t__namespace.isJSXSpreadChild(pathNodes[0]) &&
3069
+ !t__namespace.isJSXText(pathNodes[0])
3065
3070
  ) {
3066
3071
  transformedChildren =
3067
3072
  t__namespace.isCallExpression(transformedChildren) &&
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.16",
4
+ "version": "0.36.0-beta.1",
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": "764c717918d199a630bb0c7f85c7b8f772ef9e07"
34
+ "gitHead": "4078ad633c680e06c87ae5e7749c4f6e027f61e8"
35
35
  }