|
|
@ -57,54 +57,54 @@ describe('snabbdom', function() {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
describe('created element', function() {
|
|
|
|
describe('created element', function() {
|
|
|
|
it('has tag', function() {
|
|
|
|
it('has tag', function() {
|
|
|
|
patch(vnode0, h('div'));
|
|
|
|
elm = patch(vnode0, h('div')).elm;
|
|
|
|
assert.equal(elm.tagName, 'DIV');
|
|
|
|
assert.equal(elm.tagName, 'DIV');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('has different tag and id', function() {
|
|
|
|
it('has different tag and id', function() {
|
|
|
|
var elm = document.createElement('div');
|
|
|
|
var elm = document.createElement('div');
|
|
|
|
vnode0.appendChild(elm);
|
|
|
|
vnode0.appendChild(elm);
|
|
|
|
var vnode1 = h('span#id');
|
|
|
|
var vnode1 = h('span#id');
|
|
|
|
patch(elm, vnode1);
|
|
|
|
elm = patch(elm, vnode1).elm;
|
|
|
|
assert.equal(vnode1.elm.tagName, 'SPAN');
|
|
|
|
assert.equal(elm.tagName, 'SPAN');
|
|
|
|
assert.equal(vnode1.elm.id, 'id');
|
|
|
|
assert.equal(elm.id, 'id');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('has id', function() {
|
|
|
|
it('has id', function() {
|
|
|
|
patch(vnode0, h('div', [h('div#unique')]));
|
|
|
|
elm = patch(vnode0, h('div', [h('div#unique')])).elm;
|
|
|
|
assert.equal(elm.firstChild.id, 'unique');
|
|
|
|
assert.equal(elm.firstChild.id, 'unique');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('has correct namespace', function() {
|
|
|
|
it('has correct namespace', function() {
|
|
|
|
patch(vnode0, h('div', [h('div', {ns: 'http://www.w3.org/2000/svg'})]));
|
|
|
|
elm = patch(vnode0, h('div', [h('div', {ns: 'http://www.w3.org/2000/svg'})])).elm;
|
|
|
|
assert.equal(elm.firstChild.namespaceURI, 'http://www.w3.org/2000/svg');
|
|
|
|
assert.equal(elm.firstChild.namespaceURI, 'http://www.w3.org/2000/svg');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('is recieves classes in selector', function() {
|
|
|
|
it('is recieves classes in selector', function() {
|
|
|
|
patch(vnode0, h('div', [h('i.am.a.class')]));
|
|
|
|
elm = patch(vnode0, h('div', [h('i.am.a.class')])).elm;
|
|
|
|
assert(elm.firstChild.classList.contains('am'));
|
|
|
|
assert(elm.firstChild.classList.contains('am'));
|
|
|
|
assert(elm.firstChild.classList.contains('a'));
|
|
|
|
assert(elm.firstChild.classList.contains('a'));
|
|
|
|
assert(elm.firstChild.classList.contains('class'));
|
|
|
|
assert(elm.firstChild.classList.contains('class'));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('is recieves classes in class property', function() {
|
|
|
|
it('is recieves classes in class property', function() {
|
|
|
|
patch(vnode0, h('i', {class: {am: true, a: true, class: true, not: false}}));
|
|
|
|
elm = patch(vnode0, h('i', {class: {am: true, a: true, class: true, not: false}})).elm;
|
|
|
|
assert(elm.classList.contains('am'));
|
|
|
|
assert(elm.classList.contains('am'));
|
|
|
|
assert(elm.classList.contains('a'));
|
|
|
|
assert(elm.classList.contains('a'));
|
|
|
|
assert(elm.classList.contains('class'));
|
|
|
|
assert(elm.classList.contains('class'));
|
|
|
|
assert(!elm.classList.contains('not'));
|
|
|
|
assert(!elm.classList.contains('not'));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('handles classes from both selector and property', function() {
|
|
|
|
it('handles classes from both selector and property', function() {
|
|
|
|
patch(vnode0, h('div', [h('i.has', {class: {classes: true}})]));
|
|
|
|
elm = patch(vnode0, h('div', [h('i.has', {class: {classes: true}})])).elm;
|
|
|
|
assert(elm.firstChild.classList.contains('has'));
|
|
|
|
assert(elm.firstChild.classList.contains('has'));
|
|
|
|
assert(elm.firstChild.classList.contains('classes'));
|
|
|
|
assert(elm.firstChild.classList.contains('classes'));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('can create elements with text content', function() {
|
|
|
|
it('can create elements with text content', function() {
|
|
|
|
patch(vnode0, h('div', ['I am a string']));
|
|
|
|
elm = patch(vnode0, h('div', ['I am a string'])).elm;
|
|
|
|
assert.equal(elm.innerHTML, 'I am a string');
|
|
|
|
assert.equal(elm.innerHTML, 'I am a string');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('can create elements with span and text content', function() {
|
|
|
|
it('can create elements with span and text content', function() {
|
|
|
|
patch(vnode0, h('a', [h('span'), 'I am a string']));
|
|
|
|
elm = patch(vnode0, h('a', [h('span'), 'I am a string'])).elm;
|
|
|
|
assert.equal(elm.childNodes[0].tagName, 'SPAN');
|
|
|
|
assert.equal(elm.childNodes[0].tagName, 'SPAN');
|
|
|
|
assert.equal(elm.childNodes[1].textContent, 'I am a string');
|
|
|
|
assert.equal(elm.childNodes[1].textContent, 'I am a string');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('can create elements with props', function() {
|
|
|
|
it('can create elements with props', function() {
|
|
|
|
patch(vnode0, h('a', {props: {src: 'http://localhost/'}}));
|
|
|
|
elm = patch(vnode0, h('a', {props: {src: 'http://localhost/'}})).elm;
|
|
|
|
assert.equal(elm.src, 'http://localhost/');
|
|
|
|
assert.equal(elm.src, 'http://localhost/');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('can create an element created inside an iframe', function(done) {
|
|
|
|
it('can create an element created inside an iframe', function(done) {
|
|
|
@ -129,7 +129,7 @@ describe('snabbdom', function() {
|
|
|
|
var vnode1 = h('i', {class: {i: true, am: true, horse: true}});
|
|
|
|
var vnode1 = h('i', {class: {i: true, am: true, horse: true}});
|
|
|
|
var vnode2 = h('i', {class: {i: true, am: true, horse: false}});
|
|
|
|
var vnode2 = h('i', {class: {i: true, am: true, horse: false}});
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert(elm.classList.contains('i'));
|
|
|
|
assert(elm.classList.contains('i'));
|
|
|
|
assert(elm.classList.contains('am'));
|
|
|
|
assert(elm.classList.contains('am'));
|
|
|
|
assert(!elm.classList.contains('horse'));
|
|
|
|
assert(!elm.classList.contains('horse'));
|
|
|
@ -138,7 +138,7 @@ describe('snabbdom', function() {
|
|
|
|
var vnode1 = h('i', {class: {i: true, am: true, horse: true}});
|
|
|
|
var vnode1 = h('i', {class: {i: true, am: true, horse: true}});
|
|
|
|
var vnode2 = h('i', {class: {i: true, am: true, horse: false}});
|
|
|
|
var vnode2 = h('i', {class: {i: true, am: true, horse: false}});
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert(elm.classList.contains('i'));
|
|
|
|
assert(elm.classList.contains('i'));
|
|
|
|
assert(elm.classList.contains('am'));
|
|
|
|
assert(elm.classList.contains('am'));
|
|
|
|
assert(!elm.classList.contains('horse'));
|
|
|
|
assert(!elm.classList.contains('horse'));
|
|
|
@ -147,7 +147,7 @@ describe('snabbdom', function() {
|
|
|
|
var vnode1 = h('i', {class: {i: true, am: true, horse: true}});
|
|
|
|
var vnode1 = h('i', {class: {i: true, am: true, horse: true}});
|
|
|
|
var vnode2 = h('i', {class: {i: true, am: true}});
|
|
|
|
var vnode2 = h('i', {class: {i: true, am: true}});
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert(elm.classList.contains('i'));
|
|
|
|
assert(elm.classList.contains('i'));
|
|
|
|
assert(elm.classList.contains('am'));
|
|
|
|
assert(elm.classList.contains('am'));
|
|
|
|
assert(!elm.classList.contains('horse'));
|
|
|
|
assert(!elm.classList.contains('horse'));
|
|
|
@ -156,7 +156,7 @@ describe('snabbdom', function() {
|
|
|
|
var vnode1 = h('a', {props: {src: 'http://other/'}});
|
|
|
|
var vnode1 = h('a', {props: {src: 'http://other/'}});
|
|
|
|
var vnode2 = h('a', {props: {src: 'http://localhost/'}});
|
|
|
|
var vnode2 = h('a', {props: {src: 'http://localhost/'}});
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert.equal(elm.src, 'http://localhost/');
|
|
|
|
assert.equal(elm.src, 'http://localhost/');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('removes an elements props', function() {
|
|
|
|
it('removes an elements props', function() {
|
|
|
@ -178,9 +178,9 @@ describe('snabbdom', function() {
|
|
|
|
it('appends elements', function() {
|
|
|
|
it('appends elements', function() {
|
|
|
|
var vnode1 = h('span', [1].map(spanNum));
|
|
|
|
var vnode1 = h('span', [1].map(spanNum));
|
|
|
|
var vnode2 = h('span', [1, 2, 3].map(spanNum));
|
|
|
|
var vnode2 = h('span', [1, 2, 3].map(spanNum));
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
elm = patch(vnode0, vnode1).elm;
|
|
|
|
assert.equal(elm.children.length, 1);
|
|
|
|
assert.equal(elm.children.length, 1);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert.equal(elm.children.length, 3);
|
|
|
|
assert.equal(elm.children.length, 3);
|
|
|
|
assert.equal(elm.children[1].innerHTML, '2');
|
|
|
|
assert.equal(elm.children[1].innerHTML, '2');
|
|
|
|
assert.equal(elm.children[2].innerHTML, '3');
|
|
|
|
assert.equal(elm.children[2].innerHTML, '3');
|
|
|
@ -188,42 +188,42 @@ describe('snabbdom', function() {
|
|
|
|
it('prepends elements', function() {
|
|
|
|
it('prepends elements', function() {
|
|
|
|
var vnode1 = h('span', [4, 5].map(spanNum));
|
|
|
|
var vnode1 = h('span', [4, 5].map(spanNum));
|
|
|
|
var vnode2 = h('span', [1, 2, 3, 4, 5].map(spanNum));
|
|
|
|
var vnode2 = h('span', [1, 2, 3, 4, 5].map(spanNum));
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
elm = patch(vnode0, vnode1).elm;
|
|
|
|
assert.equal(elm.children.length, 2);
|
|
|
|
assert.equal(elm.children.length, 2);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['1', '2', '3', '4', '5']);
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['1', '2', '3', '4', '5']);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('add elements in the middle', function() {
|
|
|
|
it('add elements in the middle', function() {
|
|
|
|
var vnode1 = h('span', [1, 2, 4, 5].map(spanNum));
|
|
|
|
var vnode1 = h('span', [1, 2, 4, 5].map(spanNum));
|
|
|
|
var vnode2 = h('span', [1, 2, 3, 4, 5].map(spanNum));
|
|
|
|
var vnode2 = h('span', [1, 2, 3, 4, 5].map(spanNum));
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
elm = patch(vnode0, vnode1).elm;
|
|
|
|
assert.equal(elm.children.length, 4);
|
|
|
|
assert.equal(elm.children.length, 4);
|
|
|
|
assert.equal(elm.children.length, 4);
|
|
|
|
assert.equal(elm.children.length, 4);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['1', '2', '3', '4', '5']);
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['1', '2', '3', '4', '5']);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('add elements at begin and end', function() {
|
|
|
|
it('add elements at begin and end', function() {
|
|
|
|
var vnode1 = h('span', [2, 3, 4].map(spanNum));
|
|
|
|
var vnode1 = h('span', [2, 3, 4].map(spanNum));
|
|
|
|
var vnode2 = h('span', [1, 2, 3, 4, 5].map(spanNum));
|
|
|
|
var vnode2 = h('span', [1, 2, 3, 4, 5].map(spanNum));
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
elm = patch(vnode0, vnode1).elm;
|
|
|
|
assert.equal(elm.children.length, 3);
|
|
|
|
assert.equal(elm.children.length, 3);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['1', '2', '3', '4', '5']);
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['1', '2', '3', '4', '5']);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('adds children to parent with no children', function() {
|
|
|
|
it('adds children to parent with no children', function() {
|
|
|
|
var vnode1 = h('span', {key: 'span'});
|
|
|
|
var vnode1 = h('span', {key: 'span'});
|
|
|
|
var vnode2 = h('span', {key: 'span'}, [1, 2, 3].map(spanNum));
|
|
|
|
var vnode2 = h('span', {key: 'span'}, [1, 2, 3].map(spanNum));
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
elm = patch(vnode0, vnode1).elm;
|
|
|
|
assert.equal(elm.children.length, 0);
|
|
|
|
assert.equal(elm.children.length, 0);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['1', '2', '3']);
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['1', '2', '3']);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('removes all children from parent', function() {
|
|
|
|
it('removes all children from parent', function() {
|
|
|
|
var vnode1 = h('span', {key: 'span'}, [1, 2, 3].map(spanNum));
|
|
|
|
var vnode1 = h('span', {key: 'span'}, [1, 2, 3].map(spanNum));
|
|
|
|
var vnode2 = h('span', {key: 'span'});
|
|
|
|
var vnode2 = h('span', {key: 'span'});
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
elm = patch(vnode0, vnode1).elm;
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['1', '2', '3']);
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['1', '2', '3']);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert.equal(elm.children.length, 0);
|
|
|
|
assert.equal(elm.children.length, 0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -231,17 +231,17 @@ describe('snabbdom', function() {
|
|
|
|
it('removes elements from the beginning', function() {
|
|
|
|
it('removes elements from the beginning', function() {
|
|
|
|
var vnode1 = h('span', [1, 2, 3, 4, 5].map(spanNum));
|
|
|
|
var vnode1 = h('span', [1, 2, 3, 4, 5].map(spanNum));
|
|
|
|
var vnode2 = h('span', [3, 4, 5].map(spanNum));
|
|
|
|
var vnode2 = h('span', [3, 4, 5].map(spanNum));
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
elm = patch(vnode0, vnode1).elm;
|
|
|
|
assert.equal(elm.children.length, 5);
|
|
|
|
assert.equal(elm.children.length, 5);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['3', '4', '5']);
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['3', '4', '5']);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('removes elements from the end', function() {
|
|
|
|
it('removes elements from the end', function() {
|
|
|
|
var vnode1 = h('span', [1, 2, 3, 4, 5].map(spanNum));
|
|
|
|
var vnode1 = h('span', [1, 2, 3, 4, 5].map(spanNum));
|
|
|
|
var vnode2 = h('span', [1, 2, 3].map(spanNum));
|
|
|
|
var vnode2 = h('span', [1, 2, 3].map(spanNum));
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
elm = patch(vnode0, vnode1).elm;
|
|
|
|
assert.equal(elm.children.length, 5);
|
|
|
|
assert.equal(elm.children.length, 5);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert.equal(elm.children.length, 3);
|
|
|
|
assert.equal(elm.children.length, 3);
|
|
|
|
assert.equal(elm.children[0].innerHTML, '1');
|
|
|
|
assert.equal(elm.children[0].innerHTML, '1');
|
|
|
|
assert.equal(elm.children[1].innerHTML, '2');
|
|
|
|
assert.equal(elm.children[1].innerHTML, '2');
|
|
|
@ -250,9 +250,9 @@ describe('snabbdom', function() {
|
|
|
|
it('removes elements from the middle', function() {
|
|
|
|
it('removes elements from the middle', function() {
|
|
|
|
var vnode1 = h('span', [1, 2, 3, 4, 5].map(spanNum));
|
|
|
|
var vnode1 = h('span', [1, 2, 3, 4, 5].map(spanNum));
|
|
|
|
var vnode2 = h('span', [1, 2, 4, 5].map(spanNum));
|
|
|
|
var vnode2 = h('span', [1, 2, 4, 5].map(spanNum));
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
elm = patch(vnode0, vnode1).elm;
|
|
|
|
assert.equal(elm.children.length, 5);
|
|
|
|
assert.equal(elm.children.length, 5);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert.equal(elm.children.length, 4);
|
|
|
|
assert.equal(elm.children.length, 4);
|
|
|
|
assert.deepEqual(elm.children[0].innerHTML, '1');
|
|
|
|
assert.deepEqual(elm.children[0].innerHTML, '1');
|
|
|
|
assert.equal(elm.children[0].innerHTML, '1');
|
|
|
|
assert.equal(elm.children[0].innerHTML, '1');
|
|
|
@ -265,9 +265,9 @@ describe('snabbdom', function() {
|
|
|
|
it('moves element forward', function() {
|
|
|
|
it('moves element forward', function() {
|
|
|
|
var vnode1 = h('span', [1, 2, 3, 4].map(spanNum));
|
|
|
|
var vnode1 = h('span', [1, 2, 3, 4].map(spanNum));
|
|
|
|
var vnode2 = h('span', [2, 3, 1, 4].map(spanNum));
|
|
|
|
var vnode2 = h('span', [2, 3, 1, 4].map(spanNum));
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
elm = patch(vnode0, vnode1).elm;
|
|
|
|
assert.equal(elm.children.length, 4);
|
|
|
|
assert.equal(elm.children.length, 4);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert.equal(elm.children.length, 4);
|
|
|
|
assert.equal(elm.children.length, 4);
|
|
|
|
assert.equal(elm.children[0].innerHTML, '2');
|
|
|
|
assert.equal(elm.children[0].innerHTML, '2');
|
|
|
|
assert.equal(elm.children[1].innerHTML, '3');
|
|
|
|
assert.equal(elm.children[1].innerHTML, '3');
|
|
|
@ -277,9 +277,9 @@ describe('snabbdom', function() {
|
|
|
|
it('moves element to end', function() {
|
|
|
|
it('moves element to end', function() {
|
|
|
|
var vnode1 = h('span', [1, 2, 3].map(spanNum));
|
|
|
|
var vnode1 = h('span', [1, 2, 3].map(spanNum));
|
|
|
|
var vnode2 = h('span', [2, 3, 1].map(spanNum));
|
|
|
|
var vnode2 = h('span', [2, 3, 1].map(spanNum));
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
elm = patch(vnode0, vnode1).elm;
|
|
|
|
assert.equal(elm.children.length, 3);
|
|
|
|
assert.equal(elm.children.length, 3);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert.equal(elm.children.length, 3);
|
|
|
|
assert.equal(elm.children.length, 3);
|
|
|
|
assert.equal(elm.children[0].innerHTML, '2');
|
|
|
|
assert.equal(elm.children[0].innerHTML, '2');
|
|
|
|
assert.equal(elm.children[1].innerHTML, '3');
|
|
|
|
assert.equal(elm.children[1].innerHTML, '3');
|
|
|
@ -288,9 +288,9 @@ describe('snabbdom', function() {
|
|
|
|
it('moves element backwards', function() {
|
|
|
|
it('moves element backwards', function() {
|
|
|
|
var vnode1 = h('span', [1, 2, 3, 4].map(spanNum));
|
|
|
|
var vnode1 = h('span', [1, 2, 3, 4].map(spanNum));
|
|
|
|
var vnode2 = h('span', [1, 4, 2, 3].map(spanNum));
|
|
|
|
var vnode2 = h('span', [1, 4, 2, 3].map(spanNum));
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
elm = patch(vnode0, vnode1).elm;
|
|
|
|
assert.equal(elm.children.length, 4);
|
|
|
|
assert.equal(elm.children.length, 4);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert.equal(elm.children.length, 4);
|
|
|
|
assert.equal(elm.children.length, 4);
|
|
|
|
assert.equal(elm.children[0].innerHTML, '1');
|
|
|
|
assert.equal(elm.children[0].innerHTML, '1');
|
|
|
|
assert.equal(elm.children[1].innerHTML, '4');
|
|
|
|
assert.equal(elm.children[1].innerHTML, '4');
|
|
|
@ -300,9 +300,9 @@ describe('snabbdom', function() {
|
|
|
|
it('swaps first and last', function() {
|
|
|
|
it('swaps first and last', function() {
|
|
|
|
var vnode1 = h('span', [1, 2, 3, 4].map(spanNum));
|
|
|
|
var vnode1 = h('span', [1, 2, 3, 4].map(spanNum));
|
|
|
|
var vnode2 = h('span', [4, 2, 3, 1].map(spanNum));
|
|
|
|
var vnode2 = h('span', [4, 2, 3, 1].map(spanNum));
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
elm = patch(vnode0, vnode1).elm;
|
|
|
|
assert.equal(elm.children.length, 4);
|
|
|
|
assert.equal(elm.children.length, 4);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert.equal(elm.children.length, 4);
|
|
|
|
assert.equal(elm.children.length, 4);
|
|
|
|
assert.equal(elm.children[0].innerHTML, '4');
|
|
|
|
assert.equal(elm.children[0].innerHTML, '4');
|
|
|
|
assert.equal(elm.children[1].innerHTML, '2');
|
|
|
|
assert.equal(elm.children[1].innerHTML, '2');
|
|
|
@ -314,9 +314,9 @@ describe('snabbdom', function() {
|
|
|
|
it('move to left and replace', function() {
|
|
|
|
it('move to left and replace', function() {
|
|
|
|
var vnode1 = h('span', [1, 2, 3, 4, 5].map(spanNum));
|
|
|
|
var vnode1 = h('span', [1, 2, 3, 4, 5].map(spanNum));
|
|
|
|
var vnode2 = h('span', [4, 1, 2, 3, 6].map(spanNum));
|
|
|
|
var vnode2 = h('span', [4, 1, 2, 3, 6].map(spanNum));
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
elm = patch(vnode0, vnode1).elm;
|
|
|
|
assert.equal(elm.children.length, 5);
|
|
|
|
assert.equal(elm.children.length, 5);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert.equal(elm.children.length, 5);
|
|
|
|
assert.equal(elm.children.length, 5);
|
|
|
|
assert.equal(elm.children[0].innerHTML, '4');
|
|
|
|
assert.equal(elm.children[0].innerHTML, '4');
|
|
|
|
assert.equal(elm.children[1].innerHTML, '1');
|
|
|
|
assert.equal(elm.children[1].innerHTML, '1');
|
|
|
@ -327,17 +327,17 @@ describe('snabbdom', function() {
|
|
|
|
it('moves to left and leaves hole', function() {
|
|
|
|
it('moves to left and leaves hole', function() {
|
|
|
|
var vnode1 = h('span', [1, 4, 5].map(spanNum));
|
|
|
|
var vnode1 = h('span', [1, 4, 5].map(spanNum));
|
|
|
|
var vnode2 = h('span', [4, 6].map(spanNum));
|
|
|
|
var vnode2 = h('span', [4, 6].map(spanNum));
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
elm = patch(vnode0, vnode1).elm;
|
|
|
|
assert.equal(elm.children.length, 3);
|
|
|
|
assert.equal(elm.children.length, 3);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['4', '6']);
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['4', '6']);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('handles moved and set to undefined element ending at the end', function() {
|
|
|
|
it('handles moved and set to undefined element ending at the end', function() {
|
|
|
|
var vnode1 = h('span', [2, 4, 5].map(spanNum));
|
|
|
|
var vnode1 = h('span', [2, 4, 5].map(spanNum));
|
|
|
|
var vnode2 = h('span', [4, 5, 3].map(spanNum));
|
|
|
|
var vnode2 = h('span', [4, 5, 3].map(spanNum));
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
elm = patch(vnode0, vnode1).elm;
|
|
|
|
assert.equal(elm.children.length, 3);
|
|
|
|
assert.equal(elm.children.length, 3);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert.equal(elm.children.length, 3);
|
|
|
|
assert.equal(elm.children.length, 3);
|
|
|
|
assert.equal(elm.children[0].innerHTML, '4');
|
|
|
|
assert.equal(elm.children[0].innerHTML, '4');
|
|
|
|
assert.equal(elm.children[1].innerHTML, '5');
|
|
|
|
assert.equal(elm.children[1].innerHTML, '5');
|
|
|
@ -346,10 +346,10 @@ describe('snabbdom', function() {
|
|
|
|
it('moves a key in non-keyed nodes with a size up', function() {
|
|
|
|
it('moves a key in non-keyed nodes with a size up', function() {
|
|
|
|
var vnode1 = h('span', [1, 'a', 'b', 'c'].map(spanNum));
|
|
|
|
var vnode1 = h('span', [1, 'a', 'b', 'c'].map(spanNum));
|
|
|
|
var vnode2 = h('span', ['d', 'a', 'b', 'c', 1, 'e'].map(spanNum));
|
|
|
|
var vnode2 = h('span', ['d', 'a', 'b', 'c', 1, 'e'].map(spanNum));
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
elm = patch(vnode0, vnode1).elm;
|
|
|
|
assert.equal(elm.childNodes.length, 4);
|
|
|
|
assert.equal(elm.childNodes.length, 4);
|
|
|
|
assert.equal(elm.textContent, '1abc');
|
|
|
|
assert.equal(elm.textContent, '1abc');
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert.equal(elm.childNodes.length, 6);
|
|
|
|
assert.equal(elm.childNodes.length, 6);
|
|
|
|
assert.equal(elm.textContent, 'dabc1e');
|
|
|
|
assert.equal(elm.textContent, 'dabc1e');
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -357,17 +357,17 @@ describe('snabbdom', function() {
|
|
|
|
it('reverses elements', function() {
|
|
|
|
it('reverses elements', function() {
|
|
|
|
var vnode1 = h('span', [1, 2, 3, 4, 5, 6, 7, 8].map(spanNum));
|
|
|
|
var vnode1 = h('span', [1, 2, 3, 4, 5, 6, 7, 8].map(spanNum));
|
|
|
|
var vnode2 = h('span', [8, 7, 6, 5, 4, 3, 2, 1].map(spanNum));
|
|
|
|
var vnode2 = h('span', [8, 7, 6, 5, 4, 3, 2, 1].map(spanNum));
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
elm = patch(vnode0, vnode1).elm;
|
|
|
|
assert.equal(elm.children.length, 8);
|
|
|
|
assert.equal(elm.children.length, 8);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['8', '7', '6', '5', '4', '3', '2', '1']);
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['8', '7', '6', '5', '4', '3', '2', '1']);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('something', function() {
|
|
|
|
it('something', function() {
|
|
|
|
var vnode1 = h('span', [0, 1, 2, 3, 4, 5].map(spanNum));
|
|
|
|
var vnode1 = h('span', [0, 1, 2, 3, 4, 5].map(spanNum));
|
|
|
|
var vnode2 = h('span', [4, 3, 2, 1, 5, 0].map(spanNum));
|
|
|
|
var vnode2 = h('span', [4, 3, 2, 1, 5, 0].map(spanNum));
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
elm = patch(vnode0, vnode1).elm;
|
|
|
|
assert.equal(elm.children.length, 6);
|
|
|
|
assert.equal(elm.children.length, 6);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['4', '3', '2', '1', '5', '0']);
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['4', '3', '2', '1', '5', '0']);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('handles random shuffles', function() {
|
|
|
|
it('handles random shuffles', function() {
|
|
|
@ -382,7 +382,7 @@ describe('snabbdom', function() {
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
var shufArr = shuffle(arr.slice(0));
|
|
|
|
var shufArr = shuffle(arr.slice(0));
|
|
|
|
var elm = document.createElement('div');
|
|
|
|
var elm = document.createElement('div');
|
|
|
|
patch(elm, vnode1);
|
|
|
|
elm = patch(elm, vnode1).elm;
|
|
|
|
for (i = 0; i < elms; ++i) {
|
|
|
|
for (i = 0; i < elms; ++i) {
|
|
|
|
assert.equal(elm.children[i].innerHTML, i.toString());
|
|
|
|
assert.equal(elm.children[i].innerHTML, i.toString());
|
|
|
|
opacities[i] = Math.random().toFixed(5).toString();
|
|
|
|
opacities[i] = Math.random().toFixed(5).toString();
|
|
|
@ -390,7 +390,7 @@ describe('snabbdom', function() {
|
|
|
|
var vnode2 = h('span', arr.map(function(n) {
|
|
|
|
var vnode2 = h('span', arr.map(function(n) {
|
|
|
|
return spanNumWithOpacity(shufArr[n], opacities[n]);
|
|
|
|
return spanNumWithOpacity(shufArr[n], opacities[n]);
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
for (i = 0; i < elms; ++i) {
|
|
|
|
for (i = 0; i < elms; ++i) {
|
|
|
|
assert.equal(elm.children[i].innerHTML, shufArr[i].toString());
|
|
|
|
assert.equal(elm.children[i].innerHTML, shufArr[i].toString());
|
|
|
|
assert.equal(opacities[i].indexOf(elm.children[i].style.opacity), 0);
|
|
|
|
assert.equal(opacities[i].indexOf(elm.children[i].style.opacity), 0);
|
|
|
@ -402,50 +402,50 @@ describe('snabbdom', function() {
|
|
|
|
it('appends elements', function() {
|
|
|
|
it('appends elements', function() {
|
|
|
|
var vnode1 = h('div', [h('span', 'Hello')]);
|
|
|
|
var vnode1 = h('div', [h('span', 'Hello')]);
|
|
|
|
var vnode2 = h('div', [h('span', 'Hello'), h('span', 'World')]);
|
|
|
|
var vnode2 = h('div', [h('span', 'Hello'), h('span', 'World')]);
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
elm = patch(vnode0, vnode1).elm;
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['Hello']);
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['Hello']);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['Hello', 'World']);
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['Hello', 'World']);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('handles unmoved text nodes', function() {
|
|
|
|
it('handles unmoved text nodes', function() {
|
|
|
|
var vnode1 = h('div', ['Text', h('span', 'Span')]);
|
|
|
|
var vnode1 = h('div', ['Text', h('span', 'Span')]);
|
|
|
|
var vnode2 = h('div', ['Text', h('span', 'Span')]);
|
|
|
|
var vnode2 = h('div', ['Text', h('span', 'Span')]);
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
elm = patch(vnode0, vnode1).elm;
|
|
|
|
assert.equal(elm.childNodes[0].textContent, 'Text');
|
|
|
|
assert.equal(elm.childNodes[0].textContent, 'Text');
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert.equal(elm.childNodes[0].textContent, 'Text');
|
|
|
|
assert.equal(elm.childNodes[0].textContent, 'Text');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('handles changing text children', function() {
|
|
|
|
it('handles changing text children', function() {
|
|
|
|
var vnode1 = h('div', ['Text', h('span', 'Span')]);
|
|
|
|
var vnode1 = h('div', ['Text', h('span', 'Span')]);
|
|
|
|
var vnode2 = h('div', ['Text2', h('span', 'Span')]);
|
|
|
|
var vnode2 = h('div', ['Text2', h('span', 'Span')]);
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
elm = patch(vnode0, vnode1).elm;
|
|
|
|
assert.equal(elm.childNodes[0].textContent, 'Text');
|
|
|
|
assert.equal(elm.childNodes[0].textContent, 'Text');
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert.equal(elm.childNodes[0].textContent, 'Text2');
|
|
|
|
assert.equal(elm.childNodes[0].textContent, 'Text2');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('prepends element', function() {
|
|
|
|
it('prepends element', function() {
|
|
|
|
var vnode1 = h('div', [h('span', 'World')]);
|
|
|
|
var vnode1 = h('div', [h('span', 'World')]);
|
|
|
|
var vnode2 = h('div', [h('span', 'Hello'), h('span', 'World')]);
|
|
|
|
var vnode2 = h('div', [h('span', 'Hello'), h('span', 'World')]);
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
elm = patch(vnode0, vnode1).elm;
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['World']);
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['World']);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['Hello', 'World']);
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['Hello', 'World']);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('prepends element of different tag type', function() {
|
|
|
|
it('prepends element of different tag type', function() {
|
|
|
|
var vnode1 = h('div', [h('span', 'World')]);
|
|
|
|
var vnode1 = h('div', [h('span', 'World')]);
|
|
|
|
var vnode2 = h('div', [h('div', 'Hello'), h('span', 'World')]);
|
|
|
|
var vnode2 = h('div', [h('div', 'Hello'), h('span', 'World')]);
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
elm = patch(vnode0, vnode1).elm;
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['World']);
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['World']);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert.deepEqual(map(prop('tagName'), elm.children), ['DIV', 'SPAN']);
|
|
|
|
assert.deepEqual(map(prop('tagName'), elm.children), ['DIV', 'SPAN']);
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['Hello', 'World']);
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['Hello', 'World']);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('removes elements', function() {
|
|
|
|
it('removes elements', function() {
|
|
|
|
var vnode1 = h('div', [h('span', 'One'), h('span', 'Two'), h('span', 'Three')]);
|
|
|
|
var vnode1 = h('div', [h('span', 'One'), h('span', 'Two'), h('span', 'Three')]);
|
|
|
|
var vnode2 = h('div', [h('span', 'One'), h('span', 'Three')]);
|
|
|
|
var vnode2 = h('div', [h('span', 'One'), h('span', 'Three')]);
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
elm = patch(vnode0, vnode1).elm;
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['One', 'Two', 'Three']);
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['One', 'Two', 'Three']);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['One', 'Three']);
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['One', 'Three']);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('removes a single text node', function() {
|
|
|
|
it('removes a single text node', function() {
|
|
|
@ -462,7 +462,6 @@ describe('snabbdom', function() {
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
assert.equal(elm.textContent, 'One');
|
|
|
|
assert.equal(elm.textContent, 'One');
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
console.log(elm.childNodes);
|
|
|
|
|
|
|
|
assert.deepEqual(map(prop('textContent'), elm.childNodes), ['Two', 'Three']);
|
|
|
|
assert.deepEqual(map(prop('textContent'), elm.childNodes), ['Two', 'Three']);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
it('removes a text node among other elements', function() {
|
|
|
|
it('removes a text node among other elements', function() {
|
|
|
@ -478,9 +477,9 @@ describe('snabbdom', function() {
|
|
|
|
it('reorders elements', function() {
|
|
|
|
it('reorders elements', function() {
|
|
|
|
var vnode1 = h('div', [h('span', 'One'), h('div', 'Two'), h('b', 'Three')]);
|
|
|
|
var vnode1 = h('div', [h('span', 'One'), h('div', 'Two'), h('b', 'Three')]);
|
|
|
|
var vnode2 = h('div', [h('b', 'Three'), h('span', 'One'), h('div', 'Two')]);
|
|
|
|
var vnode2 = h('div', [h('b', 'Three'), h('span', 'One'), h('div', 'Two')]);
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
elm = patch(vnode0, vnode1).elm;
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['One', 'Two', 'Three']);
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['One', 'Two', 'Three']);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert.deepEqual(map(prop('tagName'), elm.children), ['B', 'SPAN', 'DIV']);
|
|
|
|
assert.deepEqual(map(prop('tagName'), elm.children), ['B', 'SPAN', 'DIV']);
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['Three', 'One', 'Two']);
|
|
|
|
assert.deepEqual(map(inner, elm.children), ['Three', 'One', 'Two']);
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -634,6 +633,23 @@ describe('snabbdom', function() {
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
assert.equal(1, result.length);
|
|
|
|
assert.equal(1, result.length);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it('calls `init` and `prepatch` listeners on root', function() {
|
|
|
|
|
|
|
|
var count = 0;
|
|
|
|
|
|
|
|
function init(vnode) {
|
|
|
|
|
|
|
|
assert.strictEqual(vnode, vnode2);
|
|
|
|
|
|
|
|
count += 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function prepatch(oldVnode, vnode) {
|
|
|
|
|
|
|
|
assert.strictEqual(vnode, vnode1);
|
|
|
|
|
|
|
|
count += 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
var vnode1 = h('div', {hook: {init: init, prepatch: prepatch}});
|
|
|
|
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
|
|
|
|
assert.equal(1, count);
|
|
|
|
|
|
|
|
var vnode2 = h('span', {hook: {init: init, prepatch: prepatch}});
|
|
|
|
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
|
|
|
|
assert.equal(2, count);
|
|
|
|
|
|
|
|
});
|
|
|
|
it('removes element when all remove listeners are done', function() {
|
|
|
|
it('removes element when all remove listeners are done', function() {
|
|
|
|
var rm1, rm2, rm3;
|
|
|
|
var rm1, rm2, rm3;
|
|
|
|
var patch = snabbdom.init([
|
|
|
|
var patch = snabbdom.init([
|
|
|
@ -641,9 +657,10 @@ describe('snabbdom', function() {
|
|
|
|
{remove: function(_, rm) { rm2 = rm; }},
|
|
|
|
{remove: function(_, rm) { rm2 = rm; }},
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
var vnode1 = h('div', [h('a', {hook: {remove: function(_, rm) { rm3 = rm; }}})]);
|
|
|
|
var vnode1 = h('div', [h('a', {hook: {remove: function(_, rm) { rm3 = rm; }}})]);
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
var vnode2 = h('div', []);
|
|
|
|
|
|
|
|
elm = patch(vnode0, vnode1).elm;
|
|
|
|
assert.equal(elm.children.length, 1);
|
|
|
|
assert.equal(elm.children.length, 1);
|
|
|
|
patch(vnode1, vnode0);
|
|
|
|
elm = patch(vnode1, vnode2).elm;
|
|
|
|
assert.equal(elm.children.length, 1);
|
|
|
|
assert.equal(elm.children.length, 1);
|
|
|
|
rm1();
|
|
|
|
rm1();
|
|
|
|
assert.equal(elm.children.length, 1);
|
|
|
|
assert.equal(elm.children.length, 1);
|
|
|
@ -700,8 +717,9 @@ describe('snabbdom', function() {
|
|
|
|
h('span', 'Child 2'),
|
|
|
|
h('span', 'Child 2'),
|
|
|
|
]),
|
|
|
|
]),
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
|
|
|
|
var vnode2 = h('div');
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
patch(vnode1, vnode0);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
assert.equal(created, 4);
|
|
|
|
assert.equal(created, 4);
|
|
|
|
assert.equal(destroyed, 4);
|
|
|
|
assert.equal(destroyed, 4);
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -717,8 +735,9 @@ describe('snabbdom', function() {
|
|
|
|
'',
|
|
|
|
'',
|
|
|
|
h('span', 'Third child'),
|
|
|
|
h('span', 'Third child'),
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
|
|
|
|
var vnode2 = h('div');
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
patch(vnode1, vnode0);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
assert.equal(created, 2);
|
|
|
|
assert.equal(created, 2);
|
|
|
|
assert.equal(removed, 2);
|
|
|
|
assert.equal(removed, 2);
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -736,8 +755,9 @@ describe('snabbdom', function() {
|
|
|
|
h('span', ['Text 1', 'Text 2']),
|
|
|
|
h('span', ['Text 1', 'Text 2']),
|
|
|
|
]),
|
|
|
|
]),
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
|
|
|
|
var vnode2 = h('div');
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
patch(vnode0, vnode1);
|
|
|
|
patch(vnode1, vnode0);
|
|
|
|
patch(vnode1, vnode2);
|
|
|
|
assert.equal(created, 4);
|
|
|
|
assert.equal(created, 4);
|
|
|
|
assert.equal(destroyed, 4);
|
|
|
|
assert.equal(destroyed, 4);
|
|
|
|
});
|
|
|
|
});
|
|
|
|