Skip to content

<svelte:component> adds unnecessary empty text nodes #4423

@shirotech

Description

@shirotech

Describe the bug
When we use a dynamic component with a wrapped if block in an each loop, it generates multiple empty text nodes for some reason.

Logs

running Svelte compiler version 3.18.2
about:srcdoc:160 Found Text Nodes <ul>​…​</ul>​ #text #text
about:srcdoc:160 Found Text Nodes <ul>​…​</ul>​ #text #text
about:srcdoc:160 Found Text Nodes <ul>​…​</ul>​ #text #text
about:srcdoc:160 Found Text Nodes <ul>​…​</ul>​ #text #text

To Reproduce
https://svelte.dev/repl/bf64c8c4fa0b4cde9b9f93cb20168354?version=3.18.2

  • Open console
  • Click Add button and observe

Expected behavior
It should not generate the extraneous empty text nodes

Information about your Svelte project:

  • Your browser and the version: (e.x. Chrome 52.1, Firefox 48.0, IE 10)
    It affects all browsers

  • Your operating system: (e.x. OS X 10, Ubuntu Linux 19.10, Windows XP, etc)
    OSX

  • Svelte version (Please check you can reproduce the issue with the latest release!)
    3.18.2

  • Whether your project uses Webpack or Rollup
    Rollup

Severity
Causes layout issues on production, very severe.

Additional context
Note that using the component directly doesn't have this issue, so I assume this behaviour is not intended and most likely a bug. https://svelte.dev/repl/4fcd86502bdc4dc68511e6856adc4646?version=3.18.2

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