timotheecour / Nim

Nim is a compiled, garbage-collected systems programming language with a design that focuses on efficiency, expressiveness, and elegance (in that order of priority).
http://nim-lang.org/
Other
2 stars 0 forks source link

Documentation dom.getComputedStyle #674

Closed juancarlospaco closed 3 years ago

juancarlospaco commented 3 years ago
# HTML DOM is not relevant in the example, any DOM node will do.
for ad in document.querySelectorAll("footer.game-ad"):
  var css = window.getComputedStyle(ad)  # This returns a Style type
  css.setProperty("display".cstring, "none".cstring)  # This Style is "read-only" in the browser, even if it is mutable in Nim

The code above complains:

Uncaught DOMException: Failed to execute 'setProperty' on 'CSSStyleDeclaration': 
These styles are computed, and therefore the 'display' property is read-only.

dom.getComputedStyle should have 2 warnings:

The returned style may or may not be read-only at run-time even if assigned to a mutable var in Nim side, maybe can be recommended to use it inside a try: ... except: ....

Not a code Bug because the thing does work using element.style.display = "none" in Nim.