Skip to content

bug: Stencil Hydrate | value.split is not a function when using <svg> #4278

Closed

Description

@mayerraphael

Prerequisites

Stencil Version

Builds based on #2938

Current Behavior

If i add an <svg> to the jsx, Stencil hydrate adds a class to this element on server-side rendering.

Upon Hydration, Stencil tries to parse the classList of this element, but an error is thrown in parseClassList function:
https://github.com/ionic-team/stencil/blob/main/src/runtime/vdom/set-accessor.ts#L157

index-1d3c5472.js:3001 TypeError: value.split is not a function
    at parseClassList (index-1d3c5472.js:1780:56)
    at setAccessor (index-1d3c5472.js:1640:32)
    at updateElement (index-1d3c5472.js:1794:17)
    at patch (index-1d3c5472.js:2193:17)
    at updateChildren (index-1d3c5472.js:2002:13)
    at patch (index-1d3c5472.js:2199:13)
    at updateChildren (index-1d3c5472.js:2002:13)
    at patch (index-1d3c5472.js:2199:13)
    at updateChildren (index-1d3c5472.js:2002:13)

The problem seems that element.className returns an SvgAnimatedString for svg-Elements instead of an expected string.

image

In the updateElement method we see that oldVNodeAttrs holds the SvgAnimatedString instead of a normal string.
image

Expected Behavior

Updating the class in Stencil Hydrate on svg Elements should work.

System Info

Stencil 2.23.2, don't know if v3 is also affected.

Steps to Reproduce

Add an <svg> element to a component. Use Stencil Hydrate and render the components server-side. Error occurs on client side hydration.

render() {
   return <svg></svg>;
}

Code Reproduction URL

Maybe later when i have time.

Additional Information

No response

Activity

  1. changed the title [-]bug: Stencil Hydrate must not use className property with svg[/-] [+]bug: Stencil Hydrate | value.split is not a function when using <svg>[/+] on Apr 18, 2023
  2. alicewriteswrongs commented on Apr 19, 2023

    @alicewriteswrongs
    Contributor

    Hey @mayerraphael thanks for filing this issue!

    If you have time, would you mind adding a reproduction case? It really helps us to diagnose and fix bugs.

  3. added
    ionitron: needs reproduction
    on Apr 19, 2023
  4. ionitron-bot commented on Apr 19, 2023

    @ionitron-bot

    Thanks for the issue! This issue has been labeled as needs reproduction. This label is added to issues that need a code reproduction.

    Please reproduce this issue in an Stencil starter component library and provide a way for us to access it (GitHub repo, StackBlitz, etc). Without a reliable code reproduction, it is unlikely we will be able to resolve the issue, leading to it being closed.

    If you have already provided a code snippet and are seeing this message, it is likely that the code snippet was not enough for our team to reproduce the issue.

    For a guide on how to create a good reproduction, see our Contributing Guide.

  5. mayerraphael commented on Apr 20, 2023

    @mayerraphael
    Author

    @alicewriteswrongs I hope i find time till tomorrow. Thanks for taking your time looking into the issue.

  6. mayerraphael commented on Aug 11, 2023

    @mayerraphael
    Author

    @alicewriteswrongs This bug seems to be related to #2938 . Other people are reporting this error there too.

  7. added
    Bug: Validated
    on Aug 11, 2023
  8. alicewriteswrongs commented on Aug 11, 2023

    @alicewriteswrongs
    Contributor
  9. removed
    Bug: Validated
    on Aug 14, 2023
  10. rwaskiewicz commented on Aug 14, 2023

    @rwaskiewicz
    Member

    👋

    FYI, I've removed the assignments/'bug: validated' labels from this issue. To echo @alicewriteswrongs @mayerraphael if you could create a minimal repro case for us, we'd greatly appreciate it!

  11. mayerraphael commented on Aug 18, 2023

    @mayerraphael
    Author

    Cant reproduce the error in an isolated example (Stencil 2.22.3/v3/v4 and NextJS 13.3). Will have to look on my part what may cause this. Weird, as i'm not the only one having this problem.

  12. mayerraphael commented on Aug 21, 2023

    @mayerraphael
    Author

    @rwaskiewicz @alicewriteswrongs I could reproduce it, finally!

    This error seems to be related to #2938 because i only get the error message on @stencil/[email protected] or the johnjenkins community version.

    Here the reproduction repository: https://github.com/mayerraphael/stencil-bug-playground

    Edit: I guess v3/v4 work correctly. SSR classes are not removed.

  13. added
    Resolution: Refine
    and removed
    ionitron: needs reproduction
    on Aug 21, 2023
  14. rwaskiewicz commented on Aug 21, 2023

    @rwaskiewicz
    Member

    Thanks @mayerraphael!

    With today's release of Stencil v4.1.0, we introduced a new flag called experimentalSlotFixes. Currently, the flag enables Stencil's pre-existing slot-related fix configuration flags. Going forward, the Stencil team is going to be working with the original author of #2938 to incrementally add the fixes in #2938 into Stencil under experimentalSlotFixes in subsequent releases.

    I've labeled this to get ingested into our backlog for us to write a test against this bug. This ought to help ensure that as we work to integrate the work from #2938 into the codebase, we don't introduce any SVG-related regressions. Thanks for your work in tracking this down for us!

  15. alicewriteswrongs commented on Sep 14, 2023

    @alicewriteswrongs
    Contributor

    Hey @mayerraphael, I just added a regression test for this issue in #4783. This should ensure that as we're fixing various slot-behavior-related issues in Stencil's runtime code we can't accidentally introduce the bug documented here into main. Since we now have that assurance I'm going to close this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Resolution: Refine

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions