Skip to content

Instantly share code, notes, and snippets.

@huang-xiao-jian
Created December 28, 2020 02:40
Show Gist options
  • Save huang-xiao-jian/c880770fdc519321a2bd10ee52dba952 to your computer and use it in GitHub Desktop.
Save huang-xiao-jian/c880770fdc519321a2bd10ee52dba952 to your computer and use it in GitHub Desktop.
Readable Preact
if (
(!oldHtml || newHtml.__html != oldHtml.__html) &&
newHtml.__html !== dom.innerHTML
) {
dom.innerHTML = (newHtml && newHtml.__html) || "";
}
// while oldHtml not null
if (!newHtml) {
dom.innerHTML = "";
}
// while newHtml not null
if (newHtml.__html != oldHtml?.__html) {
// fallback into real equality check
if (newHtml.__html !== dom.innerHTML) {
dom.innerHTML = newHtml.__html;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment