CSSStyleDeclaration-custom-properties.html 859 B

123456789101112131415161718192021222324
  1. <!DOCTYPE html>
  2. <script src="../include.js"></script>
  3. <body></body>
  4. <script>
  5. test(() => {
  6. const div = document.createElement('div');
  7. div.style.setProperty("--redcolor", "red");
  8. println(`style.getPropertyValue(--redcolor)=${div.style.getPropertyValue("--redcolor")}`);
  9. println(`style.getPropertyPriority(--redcolor)=${div.style.getPropertyPriority("--redcolor")}`);
  10. const nested = document.createElement('div');
  11. nested.style["backgroundColor"] = "var(--redcolor)";
  12. nested.style["width"] = "100px";
  13. nested.style["height"] = "100px";
  14. div.appendChild(nested);
  15. document.body.appendChild(div);
  16. println(getComputedStyle(nested).backgroundColor);
  17. div.style.removeProperty("--redcolor");
  18. println(getComputedStyle(nested).backgroundColor);
  19. });
  20. </script>