Nim is a compiled, garbage-collected systems programming language with a design that focuses on efficiency, expressiveness, and elegance (in that order of priority).
# 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.
The returned Style may be read-only at run-time in the browser.
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.
The code above complains:
dom.getComputedStyle
should have 2 warnings:Style
may be read-only at run-time in the browser.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 atry: ... except: ...
.Not a code Bug because the thing does work using
element.style.display = "none"
in Nim.