wip
This commit is contained in:
parent
0700d78fbd
commit
3d8e2f79f5
|
@ -153,10 +153,8 @@ extension FiberReconciler {
|
|||
partialResult.nextTraits
|
||||
)
|
||||
|
||||
if let n = newContent {
|
||||
existing.element = .init(from: n)
|
||||
}
|
||||
|
||||
// existing.element = newContent.map { .init(from: $0) }
|
||||
|
||||
resultChild = Result(
|
||||
fiber: existing,
|
||||
visitChildren: visitChildren(partialResult.fiber?.reconciler, nextValue),
|
||||
|
@ -169,6 +167,8 @@ extension FiberReconciler {
|
|||
)
|
||||
partialResult.nextExisting = existing.sibling
|
||||
partialResult.nextExistingAlternate = partialResult.nextExistingAlternate?.sibling
|
||||
|
||||
existing.sibling = nil
|
||||
} else {
|
||||
print("creating new")
|
||||
let elementParent = partialResult.fiber?.element != nil
|
||||
|
|
|
@ -233,7 +233,7 @@ struct ReconcilePass: FiberReconcilerPass {
|
|||
caches: FiberReconciler<R>.Caches
|
||||
) -> Mutation<R>? {
|
||||
print("reconcile(...), node:", node.fiber ?? "<nil>", "alternate:", node.fiber?.alternate ?? "<nil>")
|
||||
if let element = node.fiber?.element,
|
||||
if let element = node.fiber?.element ?? node.newContent.map({ .init(from: $0) }),
|
||||
let index = node.fiber?.elementIndex,
|
||||
let parent = node.fiber?.elementParent?.element
|
||||
{
|
||||
|
@ -242,6 +242,7 @@ struct ReconcilePass: FiberReconcilerPass {
|
|||
invalidateCache(for: fiber, in: reconciler, caches: caches)
|
||||
}
|
||||
print(" -> .insert")
|
||||
node.fiber?.element = element
|
||||
return .insert(element: element, parent: parent, index: index)
|
||||
} else if node.fiber?.typeInfo?.type != node.fiber?.alternate?.typeInfo?.type,
|
||||
let previous = node.fiber?.alternate?.element
|
||||
|
@ -253,7 +254,7 @@ struct ReconcilePass: FiberReconcilerPass {
|
|||
// This is a completely different type of view.
|
||||
return .replace(parent: parent, previous: previous, replacement: element)
|
||||
} else if let newContent = node.newContent,
|
||||
newContent != element.content
|
||||
node.fiber?.element?.content != node.fiber?.alternate?.element?.content
|
||||
{
|
||||
if let fiber = node.fiber {
|
||||
invalidateCache(for: fiber, in: reconciler, caches: caches)
|
||||
|
@ -270,6 +271,7 @@ struct ReconcilePass: FiberReconcilerPass {
|
|||
)
|
||||
)
|
||||
}
|
||||
print(" ! didn't update, content \(element.content), new content \(node.newContent as Any)")
|
||||
}
|
||||
print(" -> nil, element", node.fiber?.element != nil, "elementIndex", node.fiber?.elementIndex != nil, "elementParent", node.fiber?.elementParent?.element != nil)
|
||||
return nil
|
||||
|
|
|
@ -317,8 +317,18 @@ public struct DOMFiberRenderer: FiberRenderer {
|
|||
fatalError("The previous element does not exist (trying to replace element).")
|
||||
}
|
||||
let replacementElement = createElement(replacement)
|
||||
var grandchildren: [JSObject] = []
|
||||
|
||||
while let g = previousElement.firstChild.object {
|
||||
grandchildren.append(g)
|
||||
_ = g.remove!()
|
||||
}
|
||||
|
||||
_ = parentElement.replaceChild?(replacementElement, previousElement)
|
||||
// _ = parentElement.replaceChild?(previousElement, replacementElement)
|
||||
|
||||
for g in grandchildren {
|
||||
_ = replacementElement.appendChild!(g)
|
||||
}
|
||||
case let .update(previous, newContent, geometry):
|
||||
previous.update(with: newContent)
|
||||
guard let previousElement = previous.reference
|
||||
|
|
Loading…
Reference in New Issue