Add data-keep-attribute to reapply attribute on morphdom patch (#978)

This commit is contained in:
José Valim 2022-02-03 23:25:12 +01:00 committed by GitHub
parent 358bdb3267
commit 995082b9ab
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View file

@ -6,6 +6,10 @@ const callbacks = {
if (attr.name.startsWith("data-js-")) { if (attr.name.startsWith("data-js-")) {
to.setAttribute(attr.name, attr.value); to.setAttribute(attr.name, attr.value);
} }
if (attr.name === "data-keep-attribute") {
to.setAttribute(attr.value, from.getAttribute(attr.value));
}
} }
}, },

View file

@ -225,11 +225,13 @@ defmodule LivebookWeb.HomeLive.SessionListComponent do
<span class="font-medium">Select all</span> <span class="font-medium">Select all</span>
</button> </button>
<button class="menu-item text-gray-600" name="disconnect" type="button" <button class="menu-item text-gray-600" name="disconnect" type="button"
data-keep-attribute="disabled"
phx-click={set_action("disconnect")}> phx-click={set_action("disconnect")}>
<.remix_icon icon="shut-down-line" /> <.remix_icon icon="shut-down-line" />
<span class="font-medium">Disconnect runtime</span> <span class="font-medium">Disconnect runtime</span>
</button> </button>
<button class="menu-item text-red-600" name="close_all" type="button" <button class="menu-item text-red-600" name="close_all" type="button"
data-keep-attribute="disabled"
phx-click={set_action("close_all")}> phx-click={set_action("close_all")}>
<.remix_icon icon="close-circle-line" /> <.remix_icon icon="close-circle-line" />
<span class="font-medium">Close sessions</span> <span class="font-medium">Close sessions</span>