babel-plugin-jsx-dom-expressions 0.34.5 → 0.34.9

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 +15 -5
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -288,7 +288,7 @@ function isDynamic(path, { checkMember, checkTags, checkCallExpressions = true,
288
288
  return false;
289
289
  }
290
290
  if (
291
- (checkCallExpressions && t__namespace.isCallExpression(expr)) ||
291
+ (checkCallExpressions && (t__namespace.isCallExpression(expr) || t__namespace.isOptionalCallExpression(expr))) ||
292
292
  (checkMember &&
293
293
  (t__namespace.isMemberExpression(expr) ||
294
294
  t__namespace.isOptionalMemberExpression(expr) ||
@@ -309,6 +309,9 @@ function isDynamic(path, { checkMember, checkTags, checkCallExpressions = true,
309
309
  CallExpression(p) {
310
310
  checkCallExpressions && (dynamic = true) && p.stop();
311
311
  },
312
+ OptionalCallExpression(p) {
313
+ checkCallExpressions && (dynamic = true) && p.stop();
314
+ },
312
315
  MemberExpression(p) {
313
316
  checkMember && (dynamic = true) && p.stop();
314
317
  },
@@ -1990,6 +1993,9 @@ function createElement(path, { topLevel, hydratable }) {
1990
1993
  const tagName = getTagName(path.node),
1991
1994
  config = getConfig(path),
1992
1995
  attributes = normalizeAttributes(path);
1996
+ isDynamic(path, {
1997
+ checkMember: true
1998
+ });
1993
1999
 
1994
2000
  const filteredChildren = filterChildren(path.get("children")),
1995
2001
  multi = checkLength(filteredChildren),
@@ -2001,7 +2007,6 @@ function createElement(path, { topLevel, hydratable }) {
2001
2007
  } else {
2002
2008
  const child = transformNode(path);
2003
2009
  if (markers && child.exprs.length) memo.push(t__namespace.stringLiteral("<!--#-->"));
2004
- if (hydratable && child.exprs.length) child.exprs[0] = t__namespace.arrowFunctionExpression([], child.exprs[0]);
2005
2010
  memo.push(getCreateTemplate(config, path, child)(path, child, true));
2006
2011
  if (markers && child.exprs.length) memo.push(t__namespace.stringLiteral("<!--/-->"));
2007
2012
  }
@@ -2012,7 +2017,7 @@ function createElement(path, { topLevel, hydratable }) {
2012
2017
  if (attributes.length === 1) {
2013
2018
  transformed = attributes[0].node.argument;
2014
2019
  } else {
2015
- transformed = t__namespace.objectExpression(
2020
+ transformed = t__namespace.arrowFunctionExpression([], t__namespace.objectExpression(
2016
2021
  attributes.reduce((memo, attribute) => {
2017
2022
  const node = attribute.node;
2018
2023
 
@@ -2056,7 +2061,7 @@ function createElement(path, { topLevel, hydratable }) {
2056
2061
  }
2057
2062
  return memo;
2058
2063
  }, [])
2059
- );
2064
+ ));
2060
2065
  }
2061
2066
 
2062
2067
  const exprs = [
@@ -2064,7 +2069,12 @@ function createElement(path, { topLevel, hydratable }) {
2064
2069
  t__namespace.stringLiteral(tagName),
2065
2070
  transformed,
2066
2071
  childNodes.length
2067
- ? childNodes.length === 1
2072
+ ? hydratable
2073
+ ? t__namespace.arrowFunctionExpression(
2074
+ [],
2075
+ childNodes.length === 1 ? childNodes[0] : t__namespace.arrayExpression(childNodes)
2076
+ )
2077
+ : childNodes.length === 1
2068
2078
  ? childNodes[0]
2069
2079
  : t__namespace.arrayExpression(childNodes)
2070
2080
  : t__namespace.identifier("undefined"),
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.34.5",
4
+ "version": "0.34.9",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -27,5 +27,5 @@
27
27
  "peerDependencies": {
28
28
  "@babel/core": "^7.0.0"
29
29
  },
30
- "gitHead": "cf98663093139bb1d6847359732b2f7235d30b61"
30
+ "gitHead": "8221452594c2eb2d3d593b07759c05047dba17fa"
31
31
  }