mirror of
https://github.com/leptos-rs/leptos.git
synced 2025-12-27 16:54:41 -05:00
Compare commits
2 Commits
PenguinWit
...
link-loop
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b97cf3353a | ||
|
|
68c849073c |
@@ -47,10 +47,11 @@ macro_rules! no_attrs {
|
||||
|
||||
impl<T, Rndr> AddAnyAttr<Rndr> for BoxedView<T>
|
||||
where
|
||||
T: AddAnyAttr<Rndr> + Send,
|
||||
T: AddAnyAttr<Rndr>,
|
||||
Rndr: Renderer,
|
||||
{
|
||||
type Output<SomeNewAttr: Attribute<Rndr>> = T::Output<SomeNewAttr>;
|
||||
type Output<SomeNewAttr: Attribute<Rndr>> =
|
||||
BoxedView<T::Output<SomeNewAttr>>;
|
||||
|
||||
fn add_any_attr<NewAttr: Attribute<Rndr>>(
|
||||
self,
|
||||
@@ -59,16 +60,17 @@ where
|
||||
where
|
||||
Self::Output<NewAttr>: RenderHtml<Rndr>,
|
||||
{
|
||||
self.into_inner().add_any_attr(attr)
|
||||
BoxedView::new(self.into_inner().add_any_attr(attr))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, Rndr> AddAnyAttr<Rndr> for WrappedView<T>
|
||||
where
|
||||
T: AddAnyAttr<Rndr> + Send,
|
||||
T: AddAnyAttr<Rndr>,
|
||||
Rndr: Renderer,
|
||||
{
|
||||
type Output<SomeNewAttr: Attribute<Rndr>> = T::Output<SomeNewAttr>;
|
||||
type Output<SomeNewAttr: Attribute<Rndr>> =
|
||||
WrappedView<T::Output<SomeNewAttr>>;
|
||||
|
||||
fn add_any_attr<NewAttr: Attribute<Rndr>>(
|
||||
self,
|
||||
@@ -77,6 +79,6 @@ where
|
||||
where
|
||||
Self::Output<NewAttr>: RenderHtml<Rndr>,
|
||||
{
|
||||
self.into_inner().add_any_attr(attr)
|
||||
WrappedView::new(self.into_inner().add_any_attr(attr))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
#[cfg(feature = "ssr")]
|
||||
use super::MarkBranch;
|
||||
use super::{
|
||||
add_attr::AddAnyAttr, Mountable, Position, PositionState, Render,
|
||||
RenderHtml, WrappedView,
|
||||
add_attr::AddAnyAttr, BoxedView, Mountable, Position, PositionState,
|
||||
Render, RenderHtml,
|
||||
};
|
||||
use crate::{
|
||||
html::attribute::{
|
||||
any_attribute::{AnyAttribute, IntoAnyAttribute},
|
||||
Attribute,
|
||||
},
|
||||
hydration::Cursor,
|
||||
renderer::Renderer,
|
||||
html::attribute::Attribute, hydration::Cursor, renderer::Renderer,
|
||||
ssr::StreamBuilder,
|
||||
};
|
||||
use std::{
|
||||
@@ -54,7 +49,6 @@ where
|
||||
fn(Box<dyn Any>, &mut StreamBuilder, &mut Position, bool, bool),
|
||||
build: fn(Box<dyn Any>) -> AnyViewState<R>,
|
||||
rebuild: fn(TypeId, Box<dyn Any>, &mut AnyViewState<R>),
|
||||
add_any_attr: fn(Box<dyn Any>, AnyAttribute<R>) -> AnyView<R>,
|
||||
#[cfg(feature = "ssr")]
|
||||
#[allow(clippy::type_complexity)]
|
||||
resolve:
|
||||
@@ -296,20 +290,11 @@ where
|
||||
*state = new;
|
||||
}
|
||||
};
|
||||
|
||||
let add_any_attr = |value: Box<dyn Any>, attr: AnyAttribute<R>| {
|
||||
let value = value
|
||||
.downcast::<T>()
|
||||
.expect("AnyView::add_any_attr() couldn't downcast value");
|
||||
value.add_any_attr(attr).into_any()
|
||||
};
|
||||
|
||||
AnyView {
|
||||
type_id: TypeId::of::<T>(),
|
||||
value,
|
||||
build,
|
||||
rebuild,
|
||||
add_any_attr,
|
||||
#[cfg(feature = "ssr")]
|
||||
resolve,
|
||||
#[cfg(feature = "ssr")]
|
||||
@@ -347,18 +332,16 @@ impl<R> AddAnyAttr<R> for AnyView<R>
|
||||
where
|
||||
R: Renderer + 'static,
|
||||
{
|
||||
type Output<SomeNewAttr: Attribute<R>> = WrappedView<AnyView<R>>;
|
||||
type Output<SomeNewAttr: Attribute<R>> = Self;
|
||||
|
||||
fn add_any_attr<NewAttr: Attribute<R>>(
|
||||
self,
|
||||
attr: NewAttr,
|
||||
_attr: NewAttr,
|
||||
) -> Self::Output<NewAttr>
|
||||
where
|
||||
Self::Output<NewAttr>: RenderHtml<R>,
|
||||
{
|
||||
let attr = attr.into_cloneable_owned().into_any_attr();
|
||||
let new = (self.add_any_attr)(self.value, attr).into_any();
|
||||
WrappedView::new(new)
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -436,9 +436,9 @@ pub enum Position {
|
||||
///
|
||||
/// This is a newtype around `Box<_>` that allows us to implement rendering traits on it.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct BoxedView<T: Send>(Box<T>);
|
||||
pub struct BoxedView<T>(Box<T>);
|
||||
|
||||
impl<T: Send> BoxedView<T> {
|
||||
impl<T> BoxedView<T> {
|
||||
/// Stores view on the heap.
|
||||
pub fn new(value: T) -> Self {
|
||||
Self(Box::new(value))
|
||||
@@ -450,19 +450,19 @@ impl<T: Send> BoxedView<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Send> AsRef<T> for BoxedView<T> {
|
||||
impl<T> AsRef<T> for BoxedView<T> {
|
||||
fn as_ref(&self) -> &T {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Send> AsMut<T> for BoxedView<T> {
|
||||
impl<T> AsMut<T> for BoxedView<T> {
|
||||
fn as_mut(&mut self) -> &mut T {
|
||||
&mut self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Send> Deref for BoxedView<T> {
|
||||
impl<T> Deref for BoxedView<T> {
|
||||
type Target = T;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
@@ -470,7 +470,7 @@ impl<T: Send> Deref for BoxedView<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Send> DerefMut for BoxedView<T> {
|
||||
impl<T> DerefMut for BoxedView<T> {
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
&mut self.0
|
||||
}
|
||||
@@ -478,7 +478,7 @@ impl<T: Send> DerefMut for BoxedView<T> {
|
||||
|
||||
impl<T, Rndr> Render<Rndr> for BoxedView<T>
|
||||
where
|
||||
T: Render<Rndr> + Send,
|
||||
T: Render<Rndr>,
|
||||
Rndr: Renderer,
|
||||
{
|
||||
type State = T::State;
|
||||
@@ -494,7 +494,7 @@ where
|
||||
|
||||
impl<T, Rndr> RenderHtml<Rndr> for BoxedView<T>
|
||||
where
|
||||
T: RenderHtml<Rndr> + Send,
|
||||
T: RenderHtml<Rndr>,
|
||||
Rndr: Renderer,
|
||||
{
|
||||
type AsyncOutput = BoxedView<T::AsyncOutput>;
|
||||
@@ -532,7 +532,7 @@ where
|
||||
|
||||
impl<T> ToTemplate for BoxedView<T>
|
||||
where
|
||||
T: ToTemplate + Send,
|
||||
T: ToTemplate,
|
||||
{
|
||||
fn to_template(
|
||||
buf: &mut String,
|
||||
@@ -549,9 +549,9 @@ where
|
||||
///
|
||||
/// It is unlikely that you need this in your own work.
|
||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||
pub struct WrappedView<T: Send>(T);
|
||||
pub struct WrappedView<T>(T);
|
||||
|
||||
impl<T: Send> WrappedView<T> {
|
||||
impl<T> WrappedView<T> {
|
||||
/// Wraps the view.
|
||||
pub fn new(value: T) -> Self {
|
||||
Self(value)
|
||||
@@ -563,7 +563,7 @@ impl<T: Send> WrappedView<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Send> Deref for WrappedView<T> {
|
||||
impl<T> Deref for WrappedView<T> {
|
||||
type Target = T;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
@@ -571,19 +571,19 @@ impl<T: Send> Deref for WrappedView<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Send> DerefMut for WrappedView<T> {
|
||||
impl<T> DerefMut for WrappedView<T> {
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
&mut self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Send> AsRef<T> for WrappedView<T> {
|
||||
impl<T> AsRef<T> for WrappedView<T> {
|
||||
fn as_ref(&self) -> &T {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Send> AsMut<T> for WrappedView<T> {
|
||||
impl<T> AsMut<T> for WrappedView<T> {
|
||||
fn as_mut(&mut self) -> &mut T {
|
||||
&mut self.0
|
||||
}
|
||||
@@ -591,7 +591,7 @@ impl<T: Send> AsMut<T> for WrappedView<T> {
|
||||
|
||||
impl<T, Rndr> Render<Rndr> for WrappedView<T>
|
||||
where
|
||||
T: Render<Rndr> + Send,
|
||||
T: Render<Rndr>,
|
||||
Rndr: Renderer,
|
||||
{
|
||||
type State = T::State;
|
||||
@@ -607,7 +607,7 @@ where
|
||||
|
||||
impl<T, Rndr> RenderHtml<Rndr> for WrappedView<T>
|
||||
where
|
||||
T: RenderHtml<Rndr> + Send,
|
||||
T: RenderHtml<Rndr>,
|
||||
Rndr: Renderer,
|
||||
{
|
||||
type AsyncOutput = BoxedView<T::AsyncOutput>;
|
||||
@@ -645,7 +645,7 @@ where
|
||||
|
||||
impl<T> ToTemplate for WrappedView<T>
|
||||
where
|
||||
T: ToTemplate + Send,
|
||||
T: ToTemplate,
|
||||
{
|
||||
fn to_template(
|
||||
buf: &mut String,
|
||||
|
||||
Reference in New Issue
Block a user