Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove unsupported bound styles from Builder generator to avoid crashes #1685

Merged
merged 3 commits into from
Feb 13, 2025

Conversation

liamdebeasi
Copy link
Contributor

@liamdebeasi liamdebeasi commented Feb 13, 2025

Description

Certain styles are supported by Mitosis but not by the Builder generator. When adding these styles into Builder JSON, the Builder SDK will crash.

See a77de51 for failing test that demonstrates the issue. I've also pasted the test results below:

 FAIL  src/__tests__/builder.test.ts > Builder > drop unsupported bound styles to avoid crashes
Error: Snapshot `Builder > drop unsupported bound styles to avoid crashes 1` mismatched

- Expected
+ Received

  {
    "data": {
      "blocks": [
        {
          "@type": "@builder.io/sdk:Element",
          "actions": {},
          "bindings": {
+           "style.&:hover": " return {
+     backgroundColor: state.foo === 1 ? \"red\" : \"blue\"
+   }",
            "style.fontSize": "state.fontSize",
          },
          "children": [],
          "code": {
            "actions": {},
-           "bindings": {},
+           "bindings": {
+             "style.&:hover": "{
+     backgroundColor: state.foo === 1 ? \"red\" : \"blue\"
+   }",
+           },
          },
          "properties": {},
          "tagName": "div",
        },
      ],
      "jsCode": "",
      "tsCode": "",
    },
  }

In particular, pseudo classes are not supported on Builder elements, so those styles must be eventually moved into a global stylesheet. This means that these styles can't support state since they are pulled out into a global stylesheet.

Make sure to follow the PR preparation steps in CONTRIBUTING.md before submitting your PR:

  • format the codebase: from the root, run yarn fmt:prettier.
  • update all snapshots (in core & CLI): from the root, run yarn test:update
  • add Changeset entry: from the root, run yarn g:changeset and follow the CLI instructions. Alternatively, use the Changeset Github Bot to create the file.

Copy link

changeset-bot bot commented Feb 13, 2025

🦋 Changeset detected

Latest commit: 43d025f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@builder.io/mitosis Patch
@builder.io/mitosis-cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@liamdebeasi liamdebeasi changed the title add failing test fix: remove unsupported bound styles from Builder generator to avoid crashes Feb 13, 2025
Copy link

nx-cloud bot commented Feb 13, 2025

View your CI Pipeline Execution ↗ for commit 43d025f.

Command Status Duration Result
nx run-many --target test ✅ Succeeded 4m 45s View ↗
nx e2e @builder.io/e2e-app ✅ Succeeded 1m 12s View ↗
nx run-many --target build --exclude @builder.i... ✅ Succeeded 3m 43s View ↗
nx build @builder.io/mitosis-site ✅ Succeeded 2m 39s View ↗

☁️ Nx Cloud last updated this comment at 2025-02-13 17:50:16 UTC

@liamdebeasi liamdebeasi marked this pull request as ready for review February 13, 2025 17:44
@liamdebeasi liamdebeasi merged commit f208f94 into BuilderIO:main Feb 13, 2025
7 checks passed
@liamdebeasi liamdebeasi deleted the ld/binding-unsupported-style branch February 13, 2025 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants