Skip to content

Commit 153bb7a

Browse files
kfuledead-claudia
authored andcommitted
Add deterministic tests for nextSibling handling
1 parent f1b8d72 commit 153bb7a

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

render/tests/test-updateNodes.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,51 @@ o.spec("updateNodes", function() {
11691169
o(root.appendChild.callCount + root.insertBefore.callCount).equals(5)
11701170
o(tagNames).deepEquals(expectedTagNames)
11711171
})
1172+
o("update keyed element vnodes with another tag (#3059)", function() {
1173+
var e = function(k) {return m(k, {key: k})} // element vnode
1174+
var p = function(k) {return m(k + "p", {key: k})} // element vnode (another tag)
1175+
1176+
const o1 = [e("k1"),e("k2"),e("k3"),e("k4")]
1177+
const v1 = [p("k2"),e("k4"),e("k3")]
1178+
1179+
// create
1180+
render(root, v1)
1181+
o(Array.from(root.childNodes).map(function(n) {return n.nodeName})).deepEquals(["K2P", "K4", "K3"])
1182+
1183+
// update
1184+
render(root, [])
1185+
render(root, o1)
1186+
render(root, v1)
1187+
o(Array.from(root.childNodes).map(function(n) {return n.nodeName})).deepEquals(["K2P", "K4", "K3"])
1188+
})
1189+
o("update keyed element vnodes with dom and keyed fragment vnodes without dom (1) (#3059)", function() {
1190+
o(function() {
1191+
var e = function(k) {return m(k, {key: k})} // element vnode (with dom)
1192+
var f = function(k) {return m("[", {key: k})} // fragment vnode (without dom)
1193+
1194+
var o1 = [f("k1"),e("k2")]
1195+
var v1 = [e("k1"),e("a"),f("k2")]
1196+
1197+
render(root, o1)
1198+
render(root, v1)
1199+
1200+
o(Array.from(root.childNodes).map(function(n) {return n.nodeName})).deepEquals(["K1", "A"])
1201+
}).notThrows(Error)
1202+
})
1203+
o("update keyed element vnodes with dom and keyed fragment vnodes without dom (2) (#3059)", function() {
1204+
o(function() {
1205+
var e = function(k) {return m(k, {key: k})} // element vnode (with dom)
1206+
var f = function(k) {return m("[", {key: k})} // fragment vnode (without dom)
1207+
1208+
var o1 = [f("k1"),f("k2"),e("k3")]
1209+
var v1 = [e("k1"),f("k3"),e("k2")]
1210+
1211+
render(root, o1)
1212+
render(root, v1)
1213+
1214+
o(Array.from(root.childNodes).map(function(n) {return n.nodeName})).deepEquals(["K1", "K2"])
1215+
}).notThrows(Error)
1216+
})
11721217

11731218
components.forEach(function(cmp){
11741219
o.spec(cmp.kind, function(){

0 commit comments

Comments
 (0)