From c94a6ffb71336d57ce5d97234a08b410686d4e96 Mon Sep 17 00:00:00 2001 From: Kaede Hoshikawa Date: Sat, 8 Jan 2022 13:57:40 +0900 Subject: [PATCH 1/3] Remove start_app_as_body. --- packages/yew/src/app_handle.rs | 15 --------------- packages/yew/src/lib.rs | 26 -------------------------- 2 files changed, 41 deletions(-) diff --git a/packages/yew/src/app_handle.rs b/packages/yew/src/app_handle.rs index 04e3b79afd7..7f66c78ff45 100644 --- a/packages/yew/src/app_handle.rs +++ b/packages/yew/src/app_handle.rs @@ -4,7 +4,6 @@ use std::ops::Deref; use crate::html::{BaseComponent, NodeRef, Scope, Scoped}; -use gloo_utils::document; use std::rc::Rc; use web_sys::Element; @@ -34,20 +33,6 @@ where app } - /// Alternative to `mount_with_props` which replaces the body element with a component which - /// has a body element at the root of the HTML generated by its `view` method. Use this method - /// when you need to manipulate the body element. For example, adding/removing app-wide - /// CSS classes of the body element. - pub(crate) fn mount_as_body_with_props(props: Rc) -> Self { - let html_element = document().document_element().unwrap(); - let body_element = document().body().expect("no body node found"); - html_element - .remove_child(&body_element) - .expect("can't remove body child"); - - Self::mount_with_props(html_element, props) - } - /// Schedule the app for destruction pub fn destroy(mut self) { self.scope.destroy() diff --git a/packages/yew/src/lib.rs b/packages/yew/src/lib.rs index d988d2eccdf..b342d1c14bc 100644 --- a/packages/yew/src/lib.rs +++ b/packages/yew/src/lib.rs @@ -324,19 +324,6 @@ where start_app_with_props(COMP::Properties::default()) } -/// The main entry point of a Yew application. -/// Alternative to `start_app` which replaces the body element with a component which has a body -/// element at the root of the HTML generated by its `view` method. Use this method when you -/// need to manipulate the body element. For example, adding/removing app-wide -/// CSS classes of the body element. -pub fn start_app_as_body() -> AppHandle -where - COMP: BaseComponent, - COMP::Properties: Default, -{ - start_app_with_props_as_body(COMP::Properties::default()) -} - /// The main entry point of a Yew application. This function does the /// same as `start_app_in_element(...)` but allows to start an Yew application with properties. pub fn start_app_with_props_in_element( @@ -365,19 +352,6 @@ where ) } -/// The main entry point of a Yew application. -/// Alternative to `start_app_with_props` which replaces the body element with a component which has a body -/// element at the root of the HTML generated by its `view` method. Use this method when you -/// need to manipulate the body element. For example, adding/removing app-wide -/// CSS classes of the body element. -pub fn start_app_with_props_as_body(props: COMP::Properties) -> AppHandle -where - COMP: BaseComponent, -{ - set_default_panic_hook(); - AppHandle::::mount_as_body_with_props(Rc::new(props)) -} - /// The Yew Prelude /// /// The purpose of this module is to alleviate imports of many common types: From 8e56e0ee885191a7503ed45fd33c6aa01cfa9f91 Mon Sep 17 00:00:00 2001 From: Kaede Hoshikawa Date: Sun, 9 Jan 2022 19:58:03 +0900 Subject: [PATCH 2/3] Add migration guide. --- .../docs/migration-guides/yew/from-0_19_0-to-0_20_0.mdx | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 website/docs/migration-guides/yew/from-0_19_0-to-0_20_0.mdx diff --git a/website/docs/migration-guides/yew/from-0_19_0-to-0_20_0.mdx b/website/docs/migration-guides/yew/from-0_19_0-to-0_20_0.mdx new file mode 100644 index 00000000000..e04a30db781 --- /dev/null +++ b/website/docs/migration-guides/yew/from-0_19_0-to-0_20_0.mdx @@ -0,0 +1,8 @@ +--- +title: "From 0.19.0 to 0.20.0" +--- + +## `_as_body` variant of `start_app` is removed + +This method of controlling body has caused issues in event registration and +SSR hydration. They have been removed. From a28a5901b56fc1195fec141adb2fac5f78580b0c Mon Sep 17 00:00:00 2001 From: Kaede Hoshikawa Date: Sun, 9 Jan 2022 20:02:15 +0900 Subject: [PATCH 3/3] Update website/docs/migration-guides/yew/from-0_19_0-to-0_20_0.mdx Co-authored-by: Julius Lungys <32368314+voidpumpkin@users.noreply.github.com> --- website/docs/migration-guides/yew/from-0_19_0-to-0_20_0.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/migration-guides/yew/from-0_19_0-to-0_20_0.mdx b/website/docs/migration-guides/yew/from-0_19_0-to-0_20_0.mdx index e04a30db781..5a9292d5a28 100644 --- a/website/docs/migration-guides/yew/from-0_19_0-to-0_20_0.mdx +++ b/website/docs/migration-guides/yew/from-0_19_0-to-0_20_0.mdx @@ -5,4 +5,4 @@ title: "From 0.19.0 to 0.20.0" ## `_as_body` variant of `start_app` is removed This method of controlling body has caused issues in event registration and -SSR hydration. They have been removed. +SSR hydration. They have been removed. Read more in the [github issue](https://github.com/yewstack/yew/pull/2346).