dynamic-1.html (1026B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8"/> 5 <title>Dynamic MathML DOM</title> 6 <link rel="help" href="https://w3c.github.io/mathml-core/#dom-and-javascript"/> 7 <link rel="match" href="dynamic-1-ref.html"/> 8 <meta name="assert" content="Verify that the MathML DOM tree can be modified via javascript and that the rendering is correctly updated."> 9 <style> 10 mtext.fail { background: red; color: white; } 11 mtext.pass { background: green; color: white; } 12 </style> 13 <script> 14 window.addEventListener("DOMContentLoaded", function() { 15 var kMathMLNamespace = "http://www.w3.org/1998/Math/MathML"; 16 var mtext = document.createElementNS(kMathMLNamespace, "mtext"); 17 mtext.setAttribute("class", "pass"); 18 mtext.textContent = "PASS"; 19 var math = document.getElementsByTagNameNS(kMathMLNamespace, "math")[0]; 20 math.replaceChild(mtext, math.firstElementChild); 21 }); 22 </script> 23 </head> 24 <body> 25 <p>Test passes if you see the text "PASS".</p> 26 <math> 27 <mtext class="fail">FAIL</mtext> 28 </math> 29 </body> 30 </html>