Skip to content
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

equals #13

Open
fabiancook opened this issue Nov 5, 2021 · 1 comment
Open

equals #13

fabiancook opened this issue Nov 5, 2021 · 1 comment

Comments

@fabiancook
Copy link
Contributor

🚀 Feature Proposal

Compare and return true or false if two vnode structures are equal

Motivation

To be able to compare structures

Example

let a = (
  <container>
    <inner />
  </container>
)

function *A() {
  yield <container />
  yield <container><inner loading={true} /></container>
  yield <container><inner /></container>
}
if (await equal(a, <A />)) {
   // ???
}
@fabiancook
Copy link
Contributor Author

The initial implementation of this function is available here:

export async function equal(left: VNode, right: VNode) {

It is marked as experimental.

It will do a direct compare of the final yielded children of each node, with its relevant paired node in the same position of the vnode structure.

Only nodes that have a source reference source (string | number | ...) are compared, and only options with source reference values are compered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant