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('MutationObserver.observe on attributes', function() { | 5 describe('MutationObserver.observe on attributes', function() { |
6 it('should handle basic aspects of attribute observation', function(done) { | 6 it('should handle basic aspects of attribute observation', function(done) { |
7 var div; | 7 var div; |
8 var observer; | 8 var observer; |
9 var mutations; | 9 var mutations; |
10 | 10 |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
556 | 556 |
557 function finish() { | 557 function finish() { |
558 assert.equal(mutations, null); | 558 assert.equal(mutations, null); |
559 | 559 |
560 observer.disconnect(); | 560 observer.disconnect(); |
561 done(); | 561 done(); |
562 } | 562 } |
563 | 563 |
564 start(); | 564 start(); |
565 }); | 565 }); |
566 | |
567 it('should create records when mutating through the attribute collection', fun
ction(done) { | |
568 var observer; | |
569 var mutations; | |
570 var div; | |
571 | |
572 function start() { | |
573 observer = new MutationObserver(function(records) { | |
574 mutations = records; | |
575 }); | |
576 | |
577 div = document.createElement('div'); | |
578 div.setAttribute('data-test', 'foo'); | |
579 observer.observe(div, { attributes: true, attributeOldValue: true }); | |
580 div.attributes['data-test'].value = 'bar'; | |
581 | |
582 setTimeout(finish, 0); | |
583 } | |
584 | |
585 function finish() { | |
586 assert.equal(mutations.length, 1); | |
587 assert.equal(mutations[0].target, div); | |
588 assert.equal(mutations[0].type, "attributes"); | |
589 assert.equal(mutations[0].attributeName, "data-test"); | |
590 assert.equal(mutations[0].oldValue, "foo"); | |
591 | |
592 observer.disconnect(); | |
593 done(); | |
594 } | |
595 | |
596 start(); | |
597 }); | |
598 }); | 566 }); |
599 </script> | 567 </script> |
600 </body> | 568 </body> |
601 </html> | 569 </html> |
OLD | NEW |