Skip to content

[html] svg with dynamic attribute or text fails within a <Show> #2674

@echab

Description

@echab

Describe the bug

Within an <svg>, if the children of <Show> contain some svg elements with dynamic attributes or text, an error is thrown (it works with solid 1.9.12).

Your Example Website or App

https://stackblitz.com/edit/solidjs-templates-jrzmgmvh?file=src%2FApp.tsx

Steps to Reproduce the Bug or Issue

  1. Click on "Open Preview in new Tab" to see the error in the F12 console.

  2. Clicking on the button, the counter block at 2, with the following error (for attribute setting):

chunk-LY7APLER.js?v=c121a6f8:1126 Uncaught StatusError: node.setAttribute is not a function
    at notifyStatus (chunk-LY7APLER.js?v=c121a6f8:1126:13)
    at recompute (chunk-LY7APLER.js?v=c121a6f8:1310:5)
    at runHeap (chunk-LY7APLER.js?v=c121a6f8:125:41)
    at _GlobalQueue.flush (chunk-LY7APLER.js?v=c121a6f8:375:7)
    at flush (chunk-LY7APLER.js?v=c121a6f8:585:17)
Caused by: TypeError: node.setAttribute is not a function
    at setAttribute (@solidjs_web.js?v=f189e41d:544:13)
    at Object._effectFn (App.tsx:27:57)
    at Object.runEffect (chunk-LY7APLER.js?v=c121a6f8:1898:27)
    at effect (chunk-LY7APLER.js?v=c121a6f8:1883:118)
    at createRenderEffect (chunk-LY7APLER.js?v=c121a6f8:2038:3)
    at createRenderEffect2 (chunk-LY7APLER.js?v=c121a6f8:4093:83)
    at effect (@solidjs_web.js?v=f189e41d:438:41)
    at get children (App.tsx:26:34)
    at Show.createMemo.name [as _fn] (chunk-LY7APLER.js?v=c121a6f8:4312:27)
    at recompute (chunk-LY7APLER.js?v=c121a6f8:1293:32)
  1. comment out the third <Show> to test the last case with text setting:
chunk-LY7APLER.js?v=c121a6f8:1126 Uncaught StatusError: Failed to execute 'insertBefore' on 'Node': This node type does not support this method.
    at notifyStatus (chunk-LY7APLER.js?v=c121a6f8:1126:13)
    at recompute (chunk-LY7APLER.js?v=c121a6f8:1310:5)
    at runHeap (chunk-LY7APLER.js?v=c121a6f8:125:41)
    at _GlobalQueue.flush (chunk-LY7APLER.js?v=c121a6f8:375:7)
    at flush (chunk-LY7APLER.js?v=c121a6f8:585:17)
Caused by: HierarchyRequestError: Failed to execute 'insertBefore' on 'Node': This node type does not support this method.
    at insert (@solidjs_web.js?v=f189e41d:668:12)
    at get children (App.tsx:31:34)
    at Show.createMemo.name [as _fn] (chunk-LY7APLER.js?v=c121a6f8:4312:27)
    at recompute (chunk-LY7APLER.js?v=c121a6f8:1293:32)
    at runHeap (chunk-LY7APLER.js?v=c121a6f8:125:41)
    at _GlobalQueue.flush (chunk-LY7APLER.js?v=c121a6f8:375:7)
    at flush (chunk-LY7APLER.js?v=c121a6f8:585:17)

Expected behavior

I expect to have no error using solid2.0, with no need to wrap each dynamic elements within additional <svg>.

Screenshots or Videos

No response

Platform

  • OS: Windows, stackblitz
  • Browser: Chrome
  • Version: solidjs 2.0.0-beta.6

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions