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

bug: ion-label adds an empty comment as its first child, breaking SolidJS integration #29756

Open
3 tasks done
spion opened this issue Aug 6, 2024 · 4 comments
Open
3 tasks done
Labels

Comments

@spion
Copy link

spion commented Aug 6, 2024

Prerequisites

Ionic Framework Version

v8.x

Current Behavior

ion-label seems to add an empty HTML comment (which results with a DOM comment element). This breaks libraries such as SolidJS which make assumptions to optimize the updates when there is a single string child inside a component.

Arguably, this could be considered a SolidJS bug (ryansolid/dom-expressions#337) but the behavior is still strange.

Expected Behavior

ion-label should not produce empty comment nodes

Steps to Reproduce

Repro with SolidJS

Repro without SolidJS - using inspect element you can see that IonLabel's firstChild is not the text node, but a strange empty comment node, and that's why the timer fails to update the content and updates the comment instead.

Code Reproduction URL

https://stackblitz.com/edit/github-pyx5ga-pmauak?file=index.html

Ionic Info

N/A (stackblitz example should be sufficient)

Additional Information

No response

@ionitron-bot ionitron-bot bot added the triage label Aug 6, 2024
@spion spion changed the title bug: ion-label adds an empty comment as its first child, breaking SolidJS integratoin bug: ion-label adds an empty comment as its first child, breaking my experimental SolidJS integratoin Aug 6, 2024
@spion spion changed the title bug: ion-label adds an empty comment as its first child, breaking my experimental SolidJS integratoin bug: ion-label adds an empty comment as its first child, breaking SolidJS integration Aug 6, 2024
@sean-perkins
Copy link
Contributor

This is likely caused by the use of the emulated slot feature from Stencil that is available with scoped components. Unfortunately there is unlikely to be a quick resolution here, unless handled on Solid's end.

Ionic Framework is unlikely to move from scoped to shadow in the near term, as it is a breaking change and will require a fair amount of validation to maintain styling consistency with the existing experience.

Stencil uses the comment node for markers in the DOM for where nodes were moved from/to and I believe it may also be used when hoisting the style tags for scoped components, but I am less confident on that.

@spion
Copy link
Author

spion commented Aug 8, 2024

Hmm. I see that vdom annotations only seem to be used for hydration. Is there a way to turn them off if there is no SSR?

https://github.com/search?q=repo%3Aionic-team%2Fstencil%20insertVdomAnnotations&type=code

@sean-perkins
Copy link
Contributor

@spion are you consuming the hydrate script from Ionic Framework in your implementation? Cloudfront is returning 403s from Stackblitz right now so I'm unable to confirm.

@spion
Copy link
Author

spion commented Aug 23, 2024

I don't believe I am - this is the entire test case:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Ionic App</title>
    <script
      type="module"
      src="https://cdn.jsdelivr.net/npm/@ionic/core/dist/ionic/ionic.esm.js"
    ></script>
    <script
      nomodule
      src="https://cdn.jsdelivr.net/npm/@ionic/core/dist/ionic/ionic.js"
    ></script>
    <link
      rel="stylesheet"
      href="https://cdn.jsdelivr.net/npm/@ionic/core/css/ionic.bundle.css"
    />
  </head>
  <body>
    <ion-app>
      <ion-header>
        <ion-toolbar>
          <ion-title>Title</ion-title>
        </ion-toolbar>
      </ion-header>
      <ion-content>
        <ion-list>
          <ion-item>
            <ion-label id="test">test</ion-label>
          </ion-item>
        </ion-list>
      </ion-content>
    </ion-app>
    <script>
      setTimeout(() => {
        document.getElementById('test').firstChild.data = 'Change after 3s';
      }, 3000);
    </script>
  </body>
</html>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants