Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove start_app_as_body. #2346

Merged
merged 3 commits into from
Jan 10, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions packages/yew/src/app_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<COMP::Properties>) -> 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()
Expand Down
26 changes: 0 additions & 26 deletions packages/yew/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<COMP>() -> AppHandle<COMP>
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<COMP>(
Expand Down Expand Up @@ -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<COMP>(props: COMP::Properties) -> AppHandle<COMP>
where
COMP: BaseComponent,
{
set_default_panic_hook();
AppHandle::<COMP>::mount_as_body_with_props(Rc::new(props))
}

/// The Yew Prelude
///
/// The purpose of this module is to alleviate imports of many common types:
Expand Down
8 changes: 8 additions & 0 deletions website/docs/migration-guides/yew/from-0_19_0-to-0_20_0.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized this page is not added to the navigation bar. Could you add it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the migration guide should remain "hidden" until released, shouldn't it?

(This is the same as the yew-agent 0.1.0 -> 0.2.0 guide, which is hidden.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Showing it would make 0.19 -> next transition easier but it's something we can do later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you guys are right

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.
futursolo marked this conversation as resolved.
Show resolved Hide resolved