@builder.io/mitosis 0.5.34 → 0.5.36

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.
@@ -131,8 +131,13 @@ const BINDING_MAPPERS = {
131
131
  }
132
132
  return [ref, value];
133
133
  },
134
- innerHTML(_key, value) {
135
- return ['dangerouslySetInnerHTML', `{__html: ${value.replace(/\s+/g, ' ')}}`];
134
+ innerHTML(_key, value, _options, isProperty) {
135
+ const wrapChar = isProperty ? '"' : '';
136
+ let useValue = value.replace(/\s+/g, ' ');
137
+ if (isProperty) {
138
+ useValue = value.replace(/"/g, '\\"');
139
+ }
140
+ return ['dangerouslySetInnerHTML', `{__html: ${wrapChar}${useValue}${wrapChar}}`];
136
141
  },
137
142
  ...ATTTRIBUTE_MAPPERS,
138
143
  };
@@ -196,7 +201,7 @@ const blockToReact = (json, options, component, insideJsx, parentSlots = []) =>
196
201
  else if (BINDING_MAPPERS[key]) {
197
202
  const mapper = BINDING_MAPPERS[key];
198
203
  if (typeof mapper === 'function') {
199
- const [newKey, newValue] = mapper(key, value, options);
204
+ const [newKey, newValue] = mapper(key, value, options, true);
200
205
  str += ` ${newKey}={${newValue}} `;
201
206
  }
202
207
  else {
@@ -912,6 +912,8 @@ function convertExportDefaultToReturn(code) {
912
912
  try {
913
913
  const { types } = babel;
914
914
  const body = (0, parsers_1.parseCode)(code);
915
+ if (body.length === 0)
916
+ return code;
915
917
  const newBody = body.slice();
916
918
  for (let i = 0; i < body.length; i++) {
917
919
  const statement = body[i];
@@ -273,11 +273,9 @@ const jsxElementToJson = (node) => {
273
273
  // <Foo myProp={"hello"} />
274
274
  memo.properties[key] = expression.value;
275
275
  }
276
- else if (types.isArrowFunctionExpression(expression)) {
276
+ else if (key.startsWith('on') && types.isArrowFunctionExpression(expression)) {
277
277
  // <Foo myProp={() => {}} />
278
- const args = key.startsWith('on')
279
- ? expression.params.map((node) => node === null || node === void 0 ? void 0 : node.name)
280
- : [];
278
+ const args = expression.params.map((node) => node === null || node === void 0 ? void 0 : node.name);
281
279
  memo.bindings[key] = (0, bindings_1.createSingleBinding)({
282
280
  code: (0, generator_1.default)(expression.body, { compact: true }).code,
283
281
  async: expression.async === true ? true : undefined,
@@ -171,7 +171,10 @@ exports.components = {
171
171
  if ((_a = node === null || node === void 0 ? void 0 : node.bindings) === null || _a === void 0 ? void 0 : _a.code) {
172
172
  bindings.innerHTML = node.bindings.code;
173
173
  }
174
- return wrapOutput(node, (0, create_mitosis_node_1.createMitosisNode)({
174
+ return wrapOutput({
175
+ ...node,
176
+ properties: (0, lodash_1.omit)(node.properties, 'code'),
177
+ }, (0, create_mitosis_node_1.createMitosisNode)({
175
178
  name: node.properties.builderTag || 'div',
176
179
  properties: {
177
180
  innerHTML: node.properties.code || '',
package/package.json CHANGED
@@ -22,7 +22,7 @@
22
22
  "name": "Builder.io",
23
23
  "url": "https://www.builder.io"
24
24
  },
25
- "version": "0.5.34",
25
+ "version": "0.5.36",
26
26
  "homepage": "https://github.com/BuilderIO/mitosis",
27
27
  "main": "./dist/src/index.js",
28
28
  "exports": {