Hard
You're implementing a simple virtual DOM system. What's the correct implementation for the patch function that updates the real DOM?
1class VNode {2 constructor(type, props, children) {3 this.type = type;4 this.props = props;5 this.children = children;6 }7}89// Missing implementation10function patch(parent, newNode, oldNode, index = 0) {11 ____________________12 ____________________13 ____________________14 ____________________15}1617// Usage:18const oldVDOM = new VNode('div', { class: 'container' }, [19 new VNode('p', { class: 'text' }, ['Hello']),20]);2122const newVDOM = new VNode('div', { class: 'container' }, [23 new VNode('p', { class: 'text-bold' }, ['Hello World']),24]);2526patch(document.body, newVDOM, oldVDOM);