Skip to content

Remove 'static for Node and El #396

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

Merged
merged 2 commits into from
Mar 21, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ jobs:
profile: minimal
toolchain: stable

# @TODO remove once https://github.com/rustwasm/wasm-pack/pull/819 released
- name: Install wasm-pack
run: cargo install --git https://github.com/dalcde/wasm-pack

- name: Install cargo-make
run: cargo install cargo-make

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

[unreleased]
- Removed `'static` bound from `El` and `Node`.
- [BREAKING] Changed `perform_cmd` and `fetch` return type to `T` instead of `Result<T, T>`.
- Added Aria attributes.
- Added example `tea_component`.
Expand Down
5 changes: 1 addition & 4 deletions src/browser/dom/virtual_dom_bridge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ pub(crate) fn assign_ws_nodes_to_el<Ms>(document: &Document, el: &mut El<Ms>) {
}
}
/// Recursively create `web_sys::Node`s, and place them in the vdom Nodes' fields.
pub(crate) fn assign_ws_nodes<Ms>(document: &Document, node: &mut Node<Ms>)
where
Ms: 'static,
{
pub(crate) fn assign_ws_nodes<Ms>(document: &Document, node: &mut Node<Ms>) {
match node {
Node::Element(el) => assign_ws_nodes_to_el(document, el),
Node::Text(text) => {
Expand Down
2 changes: 1 addition & 1 deletion src/virtual_dom/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub use text::Text;
/// [`web_sys` reference](https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Node.html)
#[allow(clippy::large_enum_variant)]
#[derive(Debug)]
pub enum Node<Ms: 'static> {
pub enum Node<Ms> {
Element(El<Ms>),
// Svg(El<Ms>), // May be best to handle using namespace field on El
Text(Text),
Expand Down
2 changes: 1 addition & 1 deletion src/virtual_dom/node/el.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::borrow::Cow;
/// [MDN reference](https://developer.mozilla.org/en-US/docs/Web/API/Element)
/// [`web_sys` reference](https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Element.html)
#[derive(Debug)] // todo: Custom debug implementation where children are on new lines and indented.
pub struct El<Ms: 'static> {
pub struct El<Ms> {
// Ms is a message type, as in part of TEA.
// We call this 'El' instead of 'Element' for brevity, and to prevent
// confusion with web_sys::Element.
Expand Down
6 changes: 3 additions & 3 deletions src/virtual_dom/view.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{El, Node};

pub trait View<Ms: 'static> {
pub trait View<Ms> {
fn els(self) -> Vec<Node<Ms>>;
}

Expand All @@ -16,13 +16,13 @@ impl<Ms> View<Ms> for Vec<El<Ms>> {
}
}

impl<Ms: 'static> View<Ms> for Node<Ms> {
impl<Ms> View<Ms> for Node<Ms> {
fn els(self) -> Vec<Node<Ms>> {
vec![self]
}
}

impl<Ms: 'static> View<Ms> for Vec<Node<Ms>> {
impl<Ms> View<Ms> for Vec<Node<Ms>> {
fn els(self) -> Vec<Node<Ms>> {
self
}
Expand Down