Skip to content

Commit ce97c19

Browse files
committed
avoids problems with slow mutations by using afterMutation from can-stache-bindings tests
1 parent 3777a22 commit ce97c19

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

test/list-test.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@ var domMutateNode = require('can-dom-mutate/node');
1313
var canSymbol = require("can-symbol");
1414
var testHelpers = require('can-test-helpers');
1515
var canReflectDeps = require('can-reflect-dependencies');
16+
var globals = require("can-globals");
17+
18+
19+
// This is a helper from can-stache-bindings
20+
function afterMutation(cb) {
21+
var doc = globals.getKeyValue('document');
22+
var div = doc.createElement("div");
23+
var undo = domMutate.onNodeInsertion(div, function () {
24+
undo();
25+
doc.body.removeChild(div);
26+
setTimeout(cb, 5);
27+
});
28+
setTimeout(function () {
29+
domMutateNode.appendChild.call(doc.body, div);
30+
}, 10);
31+
}
1632

1733
QUnit.module("can-view-live.list",{
1834
setup: function(){
@@ -365,13 +381,15 @@ test("no memory leaks", function () {
365381

366382

367383
QUnit.stop();
384+
385+
368386
setTimeout(function(){
369387
domMutateNode.removeChild.call(fixture,div);
370-
setTimeout(function () {
388+
afterMutation(function () {
371389
var handlers = map[canSymbol.for("can.meta")].handlers.get([]);
372390
equal(handlers.length, 0, "there are no bindings");
373391
start();
374-
}, 50);
392+
});
375393
},10);
376394
});
377395

0 commit comments

Comments
 (0)