Skip to content
This repository has been archived by the owner on May 17, 2020. It is now read-only.
/ yew_vnode_struct Public archive

Utility for yew to log the complete VNode structure. Useful for debugging and testing

License

Notifications You must be signed in to change notification settings

spielrs/yew_vnode_struct

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Yew VNode Structure

This module contains the implementation to get all the VNode structure. it is useful for testing and debuging. For example we want to know what contain this VNode:

let example = html! {
    <div id="example">{"example"}</div>
};

Now we use VNodeStruct to get the complete Vnode button and log the result:

let vnode_example = VNodeStruct::new(example);

console.log(&format!("{:#?}", example));

We will get this in the console:

VNodeStruct {
    vtag: Some(
        VTagStruct {
            reference: None,
            attributes: {
                "id": "example",
            },
            classes: Classes {
                set: {},
            },
            value: None,
            kind: None,
            checked: false,
            node_ref: NodeRef(
                RefCell {
                    value: NodeRefInner {
                        node: None,
                        link: None,
                    },
                },
            ),
        },
    ),
    vlist: None,
    vtext: None,
    vcomp: None,
    vref: None,
    children: Some(
        [
            VNodeStruct {
                vtag: None,
                vlist: Some(
                    VList {
                        children: [
                            VText { text: example },
                        ],
                        elide_placeholder: true,
                    },
                ),
                vtext: None,
                vcomp: None,
                vref: None,
                children: Some(
                    [
                        VNodeStruct {
                            vtag: None,
                            vlist: None,
                            vtext: Some(
                                VText { text: example },
                            ),
                            vcomp: None,
                            vref: None,
                            children: None,
                        },
                    ],
                ),
            },
        ],
    ),
}

Run unit tests

cargo test

License

Spiel Request is MIT licensed. See license

About

Utility for yew to log the complete VNode structure. Useful for debugging and testing

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages