MutationObserver-callback-arguments.html (988B)
1 <!DOCTYPE HTML> 2 <meta charset=utf-8> 3 <title>MutationObserver: callback arguments</title> 4 <link rel="help" href="https://dom.spec.whatwg.org/#notify-mutation-observers"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <div id="mo-target"></div> 8 <div id="log"></div> 9 <script> 10 "use strict"; 11 12 async_test(t => { 13 const moTarget = document.querySelector("#mo-target"); 14 const mo = new MutationObserver(function(records, observer) { 15 t.step(() => { 16 assert_equals(this, mo); 17 assert_equals(arguments.length, 2); 18 assert_true(Array.isArray(records)); 19 assert_equals(records.length, 1); 20 assert_true(records[0] instanceof MutationRecord); 21 assert_equals(observer, mo); 22 23 mo.disconnect(); 24 t.done(); 25 }); 26 }); 27 28 mo.observe(moTarget, {attributes: true}); 29 moTarget.className = "trigger-mutation"; 30 }, "Callback is invoked with |this| value of MutationObserver and two arguments"); 31 </script>