OLD | NEW |
1 <html> | 1 <html> |
2 <link rel="import" href="../resources/chai.sky" /> | 2 <link rel="import" href="../resources/chai.sky" /> |
3 <link rel="import" href="../resources/mocha.sky" /> | 3 <link rel="import" href="../resources/mocha.sky" /> |
4 <script> | 4 <script> |
5 describe('Non-relevant properties on mutation records should be null, except for
NodeLists, which should be empty', function() { | 5 describe('Non-relevant properties on mutation records should be null, except for
NodeLists, which should be empty', function() { |
6 | 6 |
7 var observer = new MutationObserver(function() {}); | 7 var observer = new MutationObserver(function() {}); |
8 | 8 |
9 it('on characterData records', function() { | 9 it('on characterData records', function() { |
10 var text = document.createTextNode('something'); | 10 var text = document.createTextNode('something'); |
11 observer.observe(text, {characterData: true}); | 11 observer.observe(text, {characterData: true}); |
12 text.data = 'something else'; | 12 text.data = 'something else'; |
13 var record = observer.takeRecords()[0]; | 13 var record = observer.takeRecords()[0]; |
14 assert.isNull(record.attributeName); | 14 assert.isNull(record.attributeName); |
15 assert.isNull(record.oldValue); | 15 assert.isNull(record.oldValue); |
16 assert.isNull(record.previousSibling); | 16 assert.isNull(record.previousSibling); |
17 assert.isNull(record.nextSibling); | 17 assert.isNull(record.nextSibling); |
18 assert.equal(record.addedNodes.length, 0); | 18 assert.equal(record.addedNodes.length, 0); |
19 assert.equal(record.removedNodes.length, 0); | 19 assert.equal(record.removedNodes.length, 0); |
20 }); | 20 }); |
21 it('on childList records', function() { | 21 it('on childList records', function() { |
22 var div = document.createElement('div'); | 22 var div = document.createElement('div'); |
23 observer.observe(div, {childList: true}); | 23 observer.observe(div, {childList: true}); |
24 div.appendChild(document.createElement('span')); | 24 div.appendChild(document.createElement('span')); |
25 record = observer.takeRecords()[0]; | 25 var record = observer.takeRecords()[0]; |
26 assert.isNull(record.attributeName); | 26 assert.isNull(record.attributeName); |
27 assert.isNull(record.oldValue); | 27 assert.isNull(record.oldValue); |
28 }); | 28 }); |
29 it('on attribute records', function() { | 29 it('on attribute records', function() { |
30 var div = document.createElement('div'); | 30 var div = document.createElement('div'); |
31 observer.observe(div, {attributes: true}); | 31 observer.observe(div, {attributes: true}); |
32 div.setAttribute('data-foo', 'bar'); | 32 div.setAttribute('data-foo', 'bar'); |
33 record = observer.takeRecords()[0]; | 33 var record = observer.takeRecords()[0]; |
34 assert.isNull(record.oldValue); | 34 assert.isNull(record.oldValue); |
35 assert.isNull(record.previousSibling); | 35 assert.isNull(record.previousSibling); |
36 assert.isNull(record.nextSibling); | 36 assert.isNull(record.nextSibling); |
37 assert.equal(record.addedNodes.length, 0); | 37 assert.equal(record.addedNodes.length, 0); |
38 assert.equal(record.removedNodes.length, 0); | 38 assert.equal(record.removedNodes.length, 0); |
39 }); | 39 }); |
40 }); | 40 }); |
41 </script> | 41 </script> |
42 </html> | 42 </html> |
OLD | NEW |