Merge branch 'master' into breaking
This commit is contained in:
29 files changed
+684
-258
No files matched your search
+20
-3
@@ -9,7 +9,8 @@
|
||||
/// ```
|
||||
pub struct Config {
|
||||
pub(crate) hydrate: bool,
|
||||
pub(crate) rootname: String,
|
||||
pub(crate) root: ConfigRoot,
|
||||
pub(crate) cached_strings: Vec<String>,
|
||||
pub(crate) default_panic_hook: bool,
|
||||
}
|
||||
|
||||
@@ -17,7 +18,8 @@ impl Default for Config {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
hydrate: false,
|
||||
rootname: "main".to_string(),
|
||||
root: ConfigRoot::RootName("main".to_string()),
|
||||
cached_strings: Vec::new(),
|
||||
default_panic_hook: true,
|
||||
}
|
||||
}
|
||||
@@ -46,8 +48,18 @@ impl Config {
|
||||
/// Set the name of the element that Dioxus will use as the root.
|
||||
///
|
||||
/// This is akin to calling React.render() on the element with the specified name.
|
||||
/// Note that this only works on the current document, i.e. `window.document`.
|
||||
/// To use a different document (popup, iframe, ...) use [Self::rootelement] instead.
|
||||
pub fn rootname(mut self, name: impl Into<String>) -> Self {
|
||||
self.rootname = name.into();
|
||||
self.root = ConfigRoot::RootName(name.into());
|
||||
self
|
||||
}
|
||||
|
||||
/// Set the element that Dioxus will use as root.
|
||||
///
|
||||
/// This is akin to calling React.render() on the given element.
|
||||
pub fn rootelement(mut self, elem: web_sys::Element) -> Self {
|
||||
self.root = ConfigRoot::RootElement(elem);
|
||||
self
|
||||
}
|
||||
|
||||
@@ -59,3 +71,8 @@ impl Config {
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) enum ConfigRoot {
|
||||
RootName(String),
|
||||
RootElement(web_sys::Element),
|
||||
}
|
||||
Reference in new issue
Block a user