input-transition-1.html 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. <!DOCTYPE html>
  2. <html class="reftest-wait">
  3. <head>
  4. </head>
  5. <body>
  6. <div id="host"></div>
  7. <script>
  8. var host, root;
  9. function run() {
  10. host = document.getElementById("host");
  11. root = host.createShadowRoot();
  12. root.innerHTML = '<style>input ~ div { background: red; transition: background 100ms; } input:checked ~ div { background: green; }</style><input id="one" type="checkbox"><div style="height: 50px; width: 50px;"></div>';
  13. }
  14. function tweak() {
  15. var el = root.getElementById("one");
  16. el.checked = true;
  17. el.nextSibling.addEventListener("transitionend", function() {
  18. setTimeout(()=>{document.documentElement.removeAttribute("class")}, 1000); // wait for the checkbox SVG image to load on Android
  19. });
  20. }
  21. if (document.body.createShadowRoot) {
  22. run();
  23. window.addEventListener("MozReftestInvalidate", tweak);
  24. } else {
  25. document.documentElement.className = "";
  26. }
  27. </script>
  28. </body>
  29. </html>