make more of core private

This commit is contained in:
Evan Almloff committed 2023-07-26 16:17:48 -07:00
1 parent 6e80f15d6a
commit 2d51a1c4f2
5 files changed
+80 -30

No files matched your search

+60 -8
View File
@@ -312,19 +312,26 @@ pub struct VComponent<'a> {
/// Internally, this is used as a guarantee. Externally, this might be incorrect, so don't count on it.
///
/// This flag is assumed by the [`crate::Properties`] trait which is unsafe to implement
pub static_props: bool,
pub(crate) static_props: bool,
/// The assigned Scope for this component
pub scope: Cell<Option<ScopeId>>,
pub(crate) scope: Cell<Option<ScopeId>>,
/// The function pointer of the component, known at compile time
///
/// It is possible that components get folded at comppile time, so these shouldn't be really used as a key
pub render_fn: *const (),
pub(crate) render_fn: *const (),
pub(crate) props: RefCell<Option<Box<dyn AnyProps<'a> + 'a>>>,
}
impl<'a> VComponent<'a> {
/// Get the scope that this component is mounted to
pub fn mounted_scope(&self) -> Option<ScopeId> {
self.scope.get()
}
}
impl<'a> std::fmt::Debug for VComponent<'a> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("VComponent")
@@ -342,14 +349,36 @@ pub struct VText<'a> {
pub value: &'a str,
/// The ID of this node in the real DOM
pub id: Cell<Option<ElementId>>,
pub(crate) id: Cell<Option<ElementId>>,
}
impl<'a> VText<'a> {
/// Create a new VText
pub fn new(value: &'a str) -> Self {
Self {
value,
id: Default::default(),
}
}
/// Get the mounted ID of this node
pub fn mounted_element(&self) -> Option<ElementId> {
self.id.get()
}
}
/// A placeholder node, used by suspense and fragments
#[derive(Debug, Default)]
pub struct VPlaceholder {
/// The ID of this node in the real DOM
pub id: Cell<Option<ElementId>>,
pub(crate) id: Cell<Option<ElementId>>,
}
impl VPlaceholder {
/// Get the mounted ID of this node
pub fn mounted_element(&self) -> Option<ElementId> {
self.id.get()
}
}
/// An attribute of the TemplateNode, created at compile time
@@ -399,11 +428,34 @@ pub struct Attribute<'a> {
/// Doesn’t exist in the html spec. Used in Dioxus to denote “style” tags and other attribute groups.
pub namespace: Option<&'static str>,
/// The element in the DOM that this attribute belongs to
pub mounted_element: Cell<ElementId>,
/// An indication of we should always try and set the attribute. Used in controlled components to ensure changes are propagated
pub volatile: bool,
/// The element in the DOM that this attribute belongs to
pub(crate) mounted_element: Cell<ElementId>,
}
impl<'a> Attribute<'a> {
/// Create a new attribute
pub fn new(
name: &'a str,
value: AttributeValue<'a>,
namespace: Option<&'static str>,
volatile: bool,
) -> Self {
Self {
name,
value,
namespace,
volatile,
mounted_element: Cell::new(ElementId::default()),
}
}
/// Get the element that this attribute is mounted to
pub fn mounted_element(&self) -> ElementId {
self.mounted_element.get()
}
}
/// Any of the built-in values that the Dioxus VirtualDom supports as dynamic attributes on elements