question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

elemental2.dom.HTMLDocument missing defaultView and elemental2.dom.Window missing getComputedStyle

See original GitHub issue

For example, I wanted to do this (JSNI JavaScript) in Elemental 2: var zindex = document.defaultView.getComputedStyle(elems[i],null).getPropertyValue("z-index");

But I could not find defaultView on Document or HTMLDocument, and could not find getComputedStyle except on ViewCSS (it seems it should be on Window). What is ViewCSS and how do I achieve what I want here in Elemental 2? It seems it is not currently possible, and that my JSNI must stay for now…

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
niloc132commented, Sep 11, 2018

From https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle, it looks like you don’t need to say document.defaultView but just window (and actually both of those are wrong in JSNI, it should be $doc.defaultView and $wnd respectively).

To achieve the same thing in jsinterop with Elemental2, try this:

String zIndex = Js.<ViewCSS>cast(DomGlobal.window).getComputedStyle(elems[i]).getPropertyValue("z-index");
0reactions
jDramaixcommented, May 28, 2019

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Window.getComputedStyle() - Web APIs | MDN
The Window.getComputedStyle() method returns an object containing the values of all CSS properties of an element, after applying active ...
Read more >
How to use getComputedStyle with DOMParser produced ...
The resulting document object does not have a defaultView nor a window properties, so is there a way to call getComputedStyle() ? To...
Read more >
dom Window.getComputedStyle() - CodeProject Reference
The Window.getComputedStyle() method gives the values of all the CSS properties of an element after applying the active stylesheets and resolving any basic ......
Read more >
JavaScript Window getComputedStyle() Method - W3Schools
The getComputedStyle() method gets the computed CSS properties and values of an HTML element. The getComputedStyle() method returns a CSSStyleDeclaration object ...
Read more >
Issues - elemental2 - Google - Geeks
elemental2.dom.HTMLDocument missing defaultView and elemental2.dom.Window missing getComputedStyle. #61 opened 3 years ago.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found