How do the old js objects in react virtual dom compare with the new js objects (at the code level) how to implement

I hear it"s a sibling comparison, but how to implement
by code, such as
Old js object
{"div","class=a", {children}}
New js object
{" div","class=b", {children}}

comparison between js object and js object

1. I want to know what method (code) is used at the bottom to compare
is it traversal?

2. Did you find the child nodes behind the differences and no longer compare them? Directly delete and then regenerate?

May.19,2022

class VNode {
  constructor (tagName, props, children) {
    this.tagName = tagName
    this.props = props
    this.children = children
  } 

  render () {
    const { props, children } = this,
      dom = document.createElement(this.tagName)
    Object.entries(props).map(([key, value]) => dom.setAttribute(key, value))
    children.map(o => dom.appendChild(o instanceof VNode ? o.render() : document.createTextNode(o)))
    return dom
  }
}

const h = (tagName, props, children) => new VNode(tagName, props, children)

learn about the createClass of react


https://zhuanlan.zhihu.com/p/...

Menu