This has the interesting optimizations from #307, including:
Will remove elements with lower typeIds when considering the next node to align with.
Say we have elements 1, 2, 3, and we pass in 2. We know we can pop off 1 without further consideration (typeId is lower).
Will scan ahead elements when considering if there is a matching node, similar to key
Say we have elements div-1, span-1, div-3, and we pass in span-1. We can't pop div-1 off just yet, because typeId is not lower. But we can scan ahead for similar typeIds (until with hit the 3) to see if a matching element is ahead.
Will insert a lower typeId immediately, expecting higher ones to come.
Say we have just 2, and we pass in 1, 2. Because 2 is higher than our 1, we know we can insert immediately. Now when the 2 comes in second, we get a match.
This has the interesting optimizations from #307, including:
typeId
s when considering the next node to align with.1
,2
,3
, and we pass in2
. We know we can pop off1
without further consideration (typeId
is lower).key
div-1
,span-1
,div-3
, and we pass inspan-1
. We can't popdiv-1
off just yet, becausetypeId
is not lower. But we can scan ahead for similartypeId
s (until with hit the3
) to see if a matching element is ahead.typeId
immediately, expecting higher ones to come.2
, and we pass in1
,2
. Because2
is higher than our1
, we know we can insert immediately. Now when the2
comes in second, we get a match.Closes https://github.com/google/incremental-dom/issues/307.