@geajs/vite-plugin 1.0.20 → 1.0.21

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/dist/index.js +95 -28
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5918,12 +5918,27 @@ function generatePatchItemMethod(arrayMap, templatePropNames, wholeParamName, te
5918
5918
  t11.stringLiteral(entry.attributeName)
5919
5919
  ])
5920
5920
  ),
5921
- t11.expressionStatement(
5922
- t11.callExpression(t11.memberExpression(navExpr, t11.identifier("setAttribute")), [
5923
- t11.stringLiteral(entry.attributeName),
5924
- t11.callExpression(t11.identifier("String"), [attrVal])
5925
- ])
5926
- )
5921
+ t11.blockStatement([
5922
+ t11.variableDeclaration("const", [
5923
+ t11.variableDeclarator(t11.identifier("__newAttr"), t11.callExpression(t11.identifier("String"), [attrVal]))
5924
+ ]),
5925
+ t11.ifStatement(
5926
+ t11.binaryExpression(
5927
+ "!==",
5928
+ t11.callExpression(
5929
+ t11.memberExpression(t11.cloneNode(navExpr, true), t11.identifier("getAttribute")),
5930
+ [t11.stringLiteral(entry.attributeName)]
5931
+ ),
5932
+ t11.identifier("__newAttr")
5933
+ ),
5934
+ t11.expressionStatement(
5935
+ t11.callExpression(
5936
+ t11.memberExpression(t11.cloneNode(navExpr, true), t11.identifier("setAttribute")),
5937
+ [t11.stringLiteral(entry.attributeName), t11.identifier("__newAttr")]
5938
+ )
5939
+ )
5940
+ )
5941
+ ])
5927
5942
  )
5928
5943
  );
5929
5944
  }
@@ -6589,12 +6604,27 @@ function generateCreateItemMethod(arrayMap, templatePropNames, wholeParamName, t
6589
6604
  t11.stringLiteral(entry.attributeName)
6590
6605
  ])
6591
6606
  ),
6592
- t11.expressionStatement(
6593
- t11.callExpression(t11.memberExpression(navExpr, t11.identifier("setAttribute")), [
6594
- t11.stringLiteral(entry.attributeName),
6595
- t11.callExpression(t11.identifier("String"), [attrVal])
6596
- ])
6597
- )
6607
+ t11.blockStatement([
6608
+ t11.variableDeclaration("const", [
6609
+ t11.variableDeclarator(t11.identifier("__newAttr"), t11.callExpression(t11.identifier("String"), [attrVal]))
6610
+ ]),
6611
+ t11.ifStatement(
6612
+ t11.binaryExpression(
6613
+ "!==",
6614
+ t11.callExpression(
6615
+ t11.memberExpression(t11.cloneNode(navExpr, true), t11.identifier("getAttribute")),
6616
+ [t11.stringLiteral(entry.attributeName)]
6617
+ ),
6618
+ t11.identifier("__newAttr")
6619
+ ),
6620
+ t11.expressionStatement(
6621
+ t11.callExpression(
6622
+ t11.memberExpression(t11.cloneNode(navExpr, true), t11.identifier("setAttribute")),
6623
+ [t11.stringLiteral(entry.attributeName), t11.identifier("__newAttr")]
6624
+ )
6625
+ )
6626
+ )
6627
+ ])
6598
6628
  )
6599
6629
  );
6600
6630
  }
@@ -8530,15 +8560,32 @@ function buildPropPatcherFunction(binding, propName) {
8530
8560
  t17.callExpression(t17.identifier("String"), [t17.identifier("__attrValue")])
8531
8561
  )
8532
8562
  )
8533
- ) : t17.expressionStatement(
8534
- t17.callExpression(t17.memberExpression(target, t17.identifier("setAttribute")), [
8535
- t17.stringLiteral(attrName),
8536
- URL_ATTRS2.has(attrName) ? t17.callExpression(t17.identifier("__sanitizeAttr"), [
8537
- t17.stringLiteral(attrName),
8538
- t17.callExpression(t17.identifier("String"), [t17.identifier("__attrValue")])
8539
- ]) : t17.callExpression(t17.identifier("String"), [t17.identifier("__attrValue")])
8540
- ])
8541
- );
8563
+ ) : t17.blockStatement([
8564
+ t17.variableDeclaration("const", [
8565
+ t17.variableDeclarator(
8566
+ t17.identifier("__newAttr"),
8567
+ URL_ATTRS2.has(attrName) ? t17.callExpression(t17.identifier("__sanitizeAttr"), [
8568
+ t17.stringLiteral(attrName),
8569
+ t17.callExpression(t17.identifier("String"), [t17.identifier("__attrValue")])
8570
+ ]) : t17.callExpression(t17.identifier("String"), [t17.identifier("__attrValue")])
8571
+ )
8572
+ ]),
8573
+ t17.ifStatement(
8574
+ t17.binaryExpression(
8575
+ "!==",
8576
+ t17.callExpression(t17.memberExpression(t17.cloneNode(target, true), t17.identifier("getAttribute")), [
8577
+ t17.stringLiteral(attrName)
8578
+ ]),
8579
+ t17.identifier("__newAttr")
8580
+ ),
8581
+ t17.expressionStatement(
8582
+ t17.callExpression(t17.memberExpression(t17.cloneNode(target, true), t17.identifier("setAttribute")), [
8583
+ t17.stringLiteral(attrName),
8584
+ t17.identifier("__newAttr")
8585
+ ])
8586
+ )
8587
+ )
8588
+ ]);
8542
8589
  return t17.arrowFunctionExpression(
8543
8590
  [row, value],
8544
8591
  t17.blockStatement([
@@ -8680,12 +8727,29 @@ function buildPatchEntryPropPatcher(entry) {
8680
8727
  t17.callExpression(t17.identifier("String"), [t17.identifier("__attrValue")])
8681
8728
  )
8682
8729
  )
8683
- ) : t17.expressionStatement(
8684
- t17.callExpression(t17.memberExpression(target, t17.identifier("setAttribute")), [
8685
- t17.stringLiteral(attrName),
8686
- t17.callExpression(t17.identifier("String"), [t17.identifier("__attrValue")])
8687
- ])
8688
- );
8730
+ ) : t17.blockStatement([
8731
+ t17.variableDeclaration("const", [
8732
+ t17.variableDeclarator(
8733
+ t17.identifier("__newAttr"),
8734
+ t17.callExpression(t17.identifier("String"), [t17.identifier("__attrValue")])
8735
+ )
8736
+ ]),
8737
+ t17.ifStatement(
8738
+ t17.binaryExpression(
8739
+ "!==",
8740
+ t17.callExpression(t17.memberExpression(t17.cloneNode(target, true), t17.identifier("getAttribute")), [
8741
+ t17.stringLiteral(attrName)
8742
+ ]),
8743
+ t17.identifier("__newAttr")
8744
+ ),
8745
+ t17.expressionStatement(
8746
+ t17.callExpression(t17.memberExpression(t17.cloneNode(target, true), t17.identifier("setAttribute")), [
8747
+ t17.stringLiteral(attrName),
8748
+ t17.identifier("__newAttr")
8749
+ ])
8750
+ )
8751
+ )
8752
+ ]);
8689
8753
  return t17.arrowFunctionExpression(
8690
8754
  [row, value, item],
8691
8755
  t17.blockStatement([
@@ -9144,7 +9208,10 @@ function buildConditionalPatchStatement(binding, target, itemVariable) {
9144
9208
  if (__attrValue == null || __attrValue === false) {
9145
9209
  ${jsExpr3`${target}.removeAttribute(${binding.attributeName || "class"})`};
9146
9210
  } else {
9147
- ${jsExpr3`${target}.setAttribute(${binding.attributeName || "class"}, String(__attrValue))`};
9211
+ const __newAttr = String(__attrValue);
9212
+ if (${jsExpr3`${target}.getAttribute(${binding.attributeName || "class"})`} !== __newAttr) {
9213
+ ${jsExpr3`${target}.setAttribute(${binding.attributeName || "class"}, __newAttr)`};
9214
+ }
9148
9215
  }
9149
9216
  `
9150
9217
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geajs/vite-plugin",
3
- "version": "1.0.20",
3
+ "version": "1.0.21",
4
4
  "description": "Vite plugin for Gea framework - JSX/TSX transform, reactivity, HMR",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",