babel-plugin-jsx-dom-expressions 0.40.5 → 0.40.7

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 (3) hide show
  1. package/README.md +9 -0
  2. package/index.js +10 -6
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -175,6 +175,15 @@ Removes tags from the template output if they have no closing parents and are th
175
175
 
176
176
  Removes quotes for html attributes when possible from the template output. This may not work in all browser-like environments the same. The solution has been tested again Chrome/Edge/Firefox/Safari.
177
177
 
178
+ ### omitAttributeSpacing
179
+
180
+ - Type: `boolean`
181
+ - Default: `true`
182
+
183
+ When `true` (the default), the template output drops the whitespace between a quoted attribute and the next attribute (`<svg width="12"height="13">`). This mirrors the prior behavior and relies on the browser's HTML parser to tolerate the missing space. Some strict parsers (notably XML/SVG-only or game-engine browser-likes such as Coherent Gameface) reject the resulting markup.
184
+
185
+ Set this to `false` to emit a single space between attributes (`<svg width="12" height="13">`) so the generated HTML is strictly valid. This may also be desirable together with `omitQuotes: false` / `omitLastClosingTag: false` when targeting stricter parsers.
186
+
178
187
  ### requireImportSource
179
188
 
180
189
  - Type: `string | false`
package/index.js CHANGED
@@ -1477,7 +1477,7 @@ function transformAttributes$2(path, results) {
1477
1477
  }
1478
1478
 
1479
1479
  if (needsQuoting) {
1480
- needsSpacing = false;
1480
+ needsSpacing = !config.omitAttributeSpacing;
1481
1481
  results.template += `="${escapeHTML(text, true)}"`;
1482
1482
  } else {
1483
1483
  needsSpacing = true;
@@ -2662,11 +2662,12 @@ function escapeExpression(path, expression, attr, escapeLiterals) {
2662
2662
  expression.alternate = escapeExpression(path, expression.alternate, attr, escapeLiterals);
2663
2663
  return expression;
2664
2664
  } else if (t__namespace.isLogicalExpression(expression)) {
2665
- expression.right = escapeExpression(path, expression.right, attr, escapeLiterals);
2666
- if (expression.operator !== "&&") {
2667
- expression.left = escapeExpression(path, expression.left, attr, escapeLiterals);
2665
+ // Preserve the old short-circuit shape for && while still escaping the
2666
+ // selected result of || and ?? as a whole.
2667
+ if (expression.operator === "&&") {
2668
+ expression.right = escapeExpression(path, expression.right, attr, escapeLiterals);
2669
+ return expression;
2668
2670
  }
2669
- return expression;
2670
2671
  } else if (t__namespace.isCallExpression(expression) && t__namespace.isFunction(expression.callee)) {
2671
2672
  if (t__namespace.isBlockStatement(expression.callee.body)) {
2672
2673
  expression.callee.body.body = expression.callee.body.body.map((e) => {
@@ -2822,8 +2823,10 @@ function transformAttributes$1(path, results, info) {
2822
2823
  children = value;
2823
2824
  } else {
2824
2825
  let doEscape = true;
2826
+
2825
2827
  if (key.startsWith("attr:")) key = key.replace("attr:", "");
2826
- if (BooleanAttributes.has(key)) {
2828
+ if (BooleanAttributes.has(key) || key.startsWith("bool:")) {
2829
+ key = key.replace("bool:", "");
2827
2830
  results.template.push("");
2828
2831
  const fn = t__namespace.callExpression(registerImportMethod(attribute, "ssrAttribute"), [
2829
2832
  t__namespace.stringLiteral(key),
@@ -4305,6 +4308,7 @@ var config = {
4305
4308
  omitNestedClosingTags: false,
4306
4309
  omitLastClosingTag: true,
4307
4310
  omitQuotes: true,
4311
+ omitAttributeSpacing: true,
4308
4312
  contextToCustomElements: false,
4309
4313
  staticMarker: "@once",
4310
4314
  effectWrapper: "effect",
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.40.5",
4
+ "version": "0.40.7",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -33,5 +33,5 @@
33
33
  "@rollup/plugin-babel": "6.0.3",
34
34
  "@types/babel__core": "^7.20.5"
35
35
  },
36
- "gitHead": "d90e7885930e6bff605a1c50260577fda6506c23"
36
+ "gitHead": "3c01eb2ac61b193d4164319befe3f1b2634549cb"
37
37
  }