Heavily improved page reload

This commit is contained in:
2017-07-19 09:09:55 +02:00
parent 80264f91b8
commit cd6641cc06
3 changed files with 14 additions and 5 deletions

View File

@ -1,5 +1,6 @@
export class Diff {
static persistentClasses = new Set<string>()
static persistentAttributes = new Set<string>()
// Reuse container for diffs to avoid memory allocation
static container: HTMLElement
@ -22,7 +23,9 @@ export class Diff {
}
Diff.rootContainer.innerHTML = html.replace("<!DOCTYPE html>", "")
Diff.childNodes(aRoot, Diff.rootContainer)
console.log(aRoot.getElementsByTagName("body")[0])
console.log(Diff.rootContainer.getElementsByTagName("body")[0])
Diff.childNodes(aRoot.getElementsByTagName("body")[0], Diff.rootContainer.getElementsByTagName("body")[0])
}
// childNodes diffs the child nodes of 2 given elements and applies DOM mutations.
@ -80,7 +83,7 @@ export class Diff {
let attrib = elemA.attributes[x]
if(attrib.specified) {
if(!elemB.hasAttribute(attrib.name)) {
if(!elemB.hasAttribute(attrib.name) && !Diff.persistentAttributes.has(attrib.name)) {
removeAttributes.push(attrib)
}
}