From 2dd4b780f8e39d24066a0163c563d710527772ec Mon Sep 17 00:00:00 2001 From: Sean Doyle Date: Thu, 4 Apr 2024 15:31:22 -0400 Subject: [PATCH] Re-structure turbo-stream[action=morph] support Related to [hotwired/turbo#1240][] Since the `` hasn't yet been part of a release, there's an opportunity to rename it without being considerate of backwards compatibility. As an alternative to introduce a new Stream Action, this commit changes existing actions to be more flexible. For example, the `` element behaves like a specialized version of a ``, since it operates on the target element's `outerHTML` property. Similarly, the `` element behaves like a specialized version of a ``, since it operates on the target element's `innerHTML` property. ```diff - + - + ``` [hotwired/turbo#1240]: https://github.com/hotwired/turbo/pull/1240 --- _source/handbook/05_streams.md | 30 ++++++++++++------------ _source/reference/streams.md | 42 ++++++++++++++++------------------ 2 files changed, 34 insertions(+), 38 deletions(-) diff --git a/_source/handbook/05_streams.md b/_source/handbook/05_streams.md index 0cfc74e..c426272 100644 --- a/_source/handbook/05_streams.md +++ b/_source/handbook/05_streams.md @@ -38,6 +38,13 @@ A Turbo Streams message is a fragment of HTML consisting of `` ele + + + + + + @@ -73,22 +87,6 @@ A Turbo Streams message is a fragment of HTML consisting of `` ele - - - - - - - - ``` diff --git a/_source/reference/streams.md b/_source/reference/streams.md index b065a2b..f8aabda 100644 --- a/_source/reference/streams.md +++ b/_source/reference/streams.md @@ -46,6 +46,16 @@ Replaces the element designated by the target dom id. ``` +The `[method="morph"]` attribute can be added to the `turbo-stream` element to replace the element designated by the target dom id via morph. + +```html + + + +``` + ### Update Updates the content within the template tag to the container designated by the target dom id. @@ -58,6 +68,16 @@ Updates the content within the template tag to the container designated by the t ``` +The `[method="morph"]` attribute can be added to the `turbo-stream` element to morph only the children of the element designated by the target dom id. + +```html + + + +``` + ### Remove Removes the element designated by the target dom id. @@ -91,28 +111,6 @@ Inserts the content within the template tag after the element designated by the ``` -### Morph - -Replaces the element designated by the target dom id via morph. - -```html - - - -``` - -The `children-only` attribute can be added to the `turbo-stream` element to morph only the children of the element designated by the target dom id. - -```html - - - -``` - ### Refresh Initiates a [Page Refresh](/handbook/page_refreshes) to render new content with