Skip to content

Extraneous JS emitted using spread syntax on native tags with no explicit content #3123

@vwong

Description

@vwong

Marko Version: 6.0.155

Details

I want to wrap a native tag with a custom tag, so that I can enforce certain things like CSS, but find that this increases the bundle size.

Expected Behavior

// my-a.marko
<a ...input/>

// parent.marko
<my-a href="#my-a"/>
<a href="direct-call"/>

Both syntax in the parent component result in the same output. Ie, no JS is emitted.

Actual Behavior

JS is emitted when wrapped in a custom component. If I rewrote the custom component as:

// my-a.marko
<a href=input.href>
  <${input.content}/>
</a>

Then, I get the expected behaviour of no JS being emitted. But this syntax becomes tedious, especially compared to the first version.

Steps to Reproduce

See https://github.com/vwong/marko6-spread-optimisation. I've also included therein a partially optimised work-around.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:unverified bugA bug report that has not been verified

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions