babel-plugin-jsx-dom-expressions 0.33.0 → 0.33.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 (2) hide show
  1. package/index.js +14 -3
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -526,6 +526,7 @@ function transformElement$3(path, info) {
526
526
  config = getConfig(path),
527
527
  wrapSVG = info.topLevel && tagName != "svg" && SVGElements.has(tagName),
528
528
  voidTag = VoidElements.indexOf(tagName) > -1,
529
+ isCustomElement = tagName.indexOf("-") > -1,
529
530
  results = {
530
531
  template: `<${tagName}`,
531
532
  decl: [],
@@ -533,6 +534,7 @@ function transformElement$3(path, info) {
533
534
  dynamics: [],
534
535
  postExprs: [],
535
536
  isSVG: wrapSVG,
537
+ hasCustomElement: isCustomElement,
536
538
  tagName,
537
539
  renderer: "dom"
538
540
  };
@@ -540,7 +542,7 @@ function transformElement$3(path, info) {
540
542
  if (wrapSVG) results.template = "<svg>" + results.template;
541
543
  if (!info.skipId) results.id = path.scope.generateUidIdentifier("el$");
542
544
  transformAttributes$2(path, results);
543
- if (config.contextToCustomElements && (tagName === "slot" || tagName.indexOf("-") > -1)) {
545
+ if (config.contextToCustomElements && (tagName === "slot" || isCustomElement)) {
544
546
  contextToCustomElement(path, results);
545
547
  }
546
548
  results.template += ">";
@@ -1148,6 +1150,7 @@ function transformChildren$2(path, results, config) {
1148
1150
  results.exprs.push(...child.exprs);
1149
1151
  results.dynamics.push(...child.dynamics);
1150
1152
  results.hasHydratableEvent = results.hasHydratableEvent || child.hasHydratableEvent;
1153
+ results.hasCustomElement = results.hasCustomElement || child.hasCustomElement;
1151
1154
  tempPath = child.id.name;
1152
1155
  nextPlaceholder = null;
1153
1156
  i++;
@@ -1376,6 +1379,10 @@ function registerTemplate(path, results) {
1376
1379
  registerImportMethod(path, "getNextElement", getRendererConfig(path, "dom").moduleName),
1377
1380
  templateId ? [templateId] : []
1378
1381
  )
1382
+ : results.hasCustomElement
1383
+ ? t__namespace.callExpression(t__namespace.memberExpression(t__namespace.identifier("document"), t__namespace.identifier("importNode")), [
1384
+ templateId, t__namespace.booleanLiteral(true)
1385
+ ])
1379
1386
  : t__namespace.callExpression(t__namespace.memberExpression(templateId, t__namespace.identifier("cloneNode")), [
1380
1387
  t__namespace.booleanLiteral(true)
1381
1388
  ])
@@ -1396,7 +1403,9 @@ function wrapDynamics$1(path, dynamics) {
1396
1403
  dynamics[0].key === "classList" || dynamics[0].key === "style"
1397
1404
  ? t__namespace.identifier("_$p")
1398
1405
  : undefined;
1399
-
1406
+ if (dynamics[0].key.startsWith("class:") && !t__namespace.isBooleanLiteral(dynamics[0].value) && !t__namespace.isUnaryExpression(dynamics[0].value)) {
1407
+ dynamics[0].value = t__namespace.unaryExpression("!", t__namespace.unaryExpression("!", dynamics[0].value));
1408
+ }
1400
1409
  return t__namespace.expressionStatement(
1401
1410
  t__namespace.callExpression(effectWrapperId, [
1402
1411
  t__namespace.arrowFunctionExpression(
@@ -1417,7 +1426,9 @@ function wrapDynamics$1(path, dynamics) {
1417
1426
  prevId = t__namespace.identifier("_p$");
1418
1427
  dynamics.forEach(({ elem, key, value, isSVG, isCE }) => {
1419
1428
  const identifier = path.scope.generateUidIdentifier("v$");
1420
- identifiers.push(identifier);
1429
+ if (key.startsWith("class:") && !t__namespace.isBooleanLiteral(value) && !t__namespace.isUnaryExpression(value)) {
1430
+ value = t__namespace.unaryExpression("!", t__namespace.unaryExpression("!", value));
1431
+ } identifiers.push(identifier);
1421
1432
  decls.push(t__namespace.variableDeclarator(identifier, value));
1422
1433
  if (key === "classList" || key === "style") {
1423
1434
  const prev = t__namespace.memberExpression(prevId, identifier);
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.33.0",
4
+ "version": "0.33.7",
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": "1f388eacd1601e06e84689837a5363f13ae5ffe7"
26
+ "gitHead": "adea58b5d73a28af4f95afcb4d05f2418433e696"
27
27
  }