mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-12-03 17:39:11 +00:00
allow registering custom element and fix deadlock
This commit is contained in:
parent
60be849ff0
commit
500a73abae
1 changed files with 7 additions and 2 deletions
|
@ -10,7 +10,7 @@ use std::collections::VecDeque;
|
|||
use std::ops::{Deref, DerefMut};
|
||||
use std::sync::{Arc, RwLock};
|
||||
|
||||
use crate::custom_element::{CustomElementManager, CustomElementRegistry};
|
||||
use crate::custom_element::{CustomElement, CustomElementManager, CustomElementRegistry};
|
||||
use crate::node::{
|
||||
ElementNode, FromAnyValue, NodeType, OwnedAttributeDiscription, OwnedAttributeValue, TextNode,
|
||||
};
|
||||
|
@ -206,7 +206,7 @@ impl<V: FromAnyValue + Send + Sync> RealDom<V> {
|
|||
if is_element {
|
||||
let custom_elements = self.custom_elements.clone();
|
||||
custom_elements
|
||||
.write()
|
||||
.read()
|
||||
.unwrap()
|
||||
.add_shadow_dom(NodeMut::new(id, self));
|
||||
}
|
||||
|
@ -426,6 +426,11 @@ impl<V: FromAnyValue + Send + Sync> RealDom<V> {
|
|||
pub fn raw_world_mut(&mut self) -> &mut World {
|
||||
&mut self.world
|
||||
}
|
||||
|
||||
/// Registers a new custom element.
|
||||
pub fn register_custom_element<E: CustomElement<V>>(&mut self) {
|
||||
self.custom_elements.write().unwrap().register::<E>()
|
||||
}
|
||||
}
|
||||
|
||||
/// A reference to a tracked component in a node.
|
||||
|
|
Loading…
Reference in a new issue