Skip to content

Bug: using ":attrs", attribute is repeated twice if specified in parent component #287

@danjac

Description

@danjac

Django 5.2
Python 3.13
Django-cotton 2.1.1

Inner component:

<c-vars :action="request.path"
        method="post"
        class="space-y-3"
/>
<form class="{{ class }}"
      action="{{ action }}"
      method="{{ method }}"
      {{ attrs }}>
        {% csrf_token %}
        {{ slot }}
</form>

Outer component:

<c-vars
    :hx-post="request.path"
    hx-target="this"
    hx-swap="outerHTML"
/>
<c-form :hx-post=action
        :hx-target=hx_target
        :hx-swap=hx_swap
        :action=hx_post
        :attrs="attrs">
    {{ slot }}
</c-form>

Calling the component:

        <c-form.hx-form id="preferences-form" hx-post="/prefs">
        .....content here
        </c-form.hx-form>

Rendered result:

<form class="space-y-3"
      action="/prefs"
      method="post"
      hx-target="this" 
     hx-swap="outerHTML" 
     action="/prefs" 
    id="preferences-form" 
   hx-post="/prefs">

The action attribute is rendered twice: attributes should be just rendered once.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions