Skip to content

Instantly share code, notes, and snippets.

@Tevinthuku
Last active August 13, 2019 19:53
Show Gist options
  • Save Tevinthuku/f4608548dad9d400f9a3b6289711cccd to your computer and use it in GitHub Desktop.
Save Tevinthuku/f4608548dad9d400f9a3b6289711cccd to your computer and use it in GitHub Desktop.
function reconcile(parentDom, instance, element) {
/** code... */
else if (instance.element.type === element.type) {
// perform props update here
updateDomProperties(instance.dom, instance.element.props, element.props);
instance.childInstances = reconcileChildren(instance, element);
instance.element = element;
return instance;
}
/** code... */
}
function instantiate(element) {
const { type, props } = element;
/** code... */
const dom = isTextElement
? document.createTextNode("")
: document.createElement(type);
// apply new props and provide empty object as a prevObject since this is instanciation
updateDomProperties(dom, {}, props);
/** code... */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment