Skip to content

Duplicating DOM elements with before and after turbo streams actions #1288

Open
@ExceLLent404

Description

The problem is similar to what #240 solved for append and prepend actions. But not for before and after actions.

Streams reference for append action says:

If the template’s first element has an id that is already used by a direct child inside the container targeted by dom_id, it is replaced instead of appended.

The same for prepend.

However, the described behavior does not apply to the before and after actions.

The problem:

Assuming there is the following HTML

<div id="top"></div>
<div id="middle"></div>
<div id="bottom"></div>

then such turbo stream element with before action

<turbo-stream action="before" target="bottom">
  <template>
      <div id="middle"></div>
  </template>
</turbo-stream>

or with after action

<turbo-stream action="after" target="top">
  <template>
      <div id="middle"></div>
  </template>
</turbo-stream>

will produce DOM with elements with duplicated id

<div id="top"></div>
<div id="middle"></div>
<div id="middle"></div>
<div id="bottom"></div>

Activity

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

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