Version: 0.0.10.0.20.1.00.1.10.2.00.2.10.2.20.2.30.2.40.3.00.3.10.3.20.3.30.3.40.3.50.3.60.4.00.5.00.5.10.6.00.6.10.6.20.7.00.7.10.7.20.7.30.7.40.7.50.8.00.8.10.9.00.9.11.0.01.0.11.0.21.0.31.0.41.0.51.0.71.1.01.1.11.2.01.2.11.2.21.2.31.2.41.2.51.3.01.4.01.4.11.4.21.4.31.4.41.4.51.4.61.4.71.4.81.4.91.4.101.5.01.5.12.0.02.0.12.0.22.0.32.0.42.0.52.0.62.0.72.0.82.0.92.1.02.1.12.1.22.1.32.1.42.1.52.1.62.1.72.1.82.2.02.2.12.3.02.3.12.3.22.3.32.3.42.4.02.4.12.4.22.4.32.4.42.4.52.4.62.4.72.4.82.4.92.4.102.4.112.5.02.5.12.5.22.5.32.6.02.6.12.6.22.6.32.6.42.6.53.0.03.1.03.1.13.1.33.1.43.2.03.2.1
import {patchElement} from './utils/patchElement'
import {recycleElement} from './utils/recycleElement'
/**
* @description A function to patch a virtual node agains a DOM element, updating it in the most efficient manner possible.
* @param {object} node A virtual node. This may be a JSX tag or a hyperscript function.
* @param {HTMLElement} element The element to patch.
* @returns {HTMLElement} The updated element.
*/
export function patch(node, element) {
if (element) {
patchElement(
element.parentNode,
element,
element.node == null
? recycleElement(element, [].map)
: element.node,
node,
)
} else {
element = patchElement(
null,
node
}
element.node = node
return element