Questions tagged [cssom]

CSSOM defines APIs (including generic parsing and serialization rules) for Media Queries, Selectors, and CSS itself.

The core features of the CSSOM are oriented towards providing basic capabilities to author-defined scripts to permit access to and manipulation of style related state information and processes.

Documentation: http://dev.w3.org/csswg/cssom/

64 questions
46
votes
3 answers

Are deferred scripts executed before DOMContentLoaded event?

Upon defer attribute MDN says: This Boolean attribute is set to indicate to a browser that the script is meant to be executed after the document has been parsed, but before firing DOMContentLoaded. The defer attribute should only be used on…
user31782
  • 7,087
  • 14
  • 68
  • 143
20
votes
4 answers

Why were window.scrollY and window.scrollX introduced?

As far as I know, pageXOffset/pageYOffset properties were already available since Netscape 4 era. And it seems scrollX/scrollY were introduced circa Netscape 6. Alternative question: Q2. Is there a browser which implements scrollX/scrollY but…
Knu
  • 14,806
  • 5
  • 56
  • 89
13
votes
3 answers

Uncaught DOMException: Failed to read the 'rules' property from 'CSSStyleSheet'

In Code.org's App Lab editor, we recently started seeing this error in Chrome 64: Uncaught DOMException: Failed to read the 'rules' property from 'CSSStyleSheet' The error is thrown in this function designed to detect whether CSS media queries are…
Brad Buchanan
  • 1,475
  • 1
  • 15
  • 22
12
votes
2 answers

Why doesn't getComputedStyle take into account margin collapsing?

Concerning in-browser Javascript, the window.getComputedStyle() method is supposed to give the final used values of the CSS properties applied to an element. According to the MDN documentation, that means “after all calculations have been…
10
votes
4 answers

Why does scrollWidth only include the left padding?

So, I have a DIV #Wrapper which has a fixed width. Inside that DIV, I have another DIV #Panel which also has a fixed width:

...

Panel

...

Sometimes, the width of the Panel…
Šime Vidas
  • 182,163
  • 62
  • 281
  • 385
9
votes
4 answers

If CSS is render-blocking, why do we see FOUC?

In order to construct the render-tree, the browser requires both DOM and CSSOM. CSSOM can only be constructed, once the CSS is downloaded. In essence, once the CSS is downloaded the page should be rendered alright. But, why do we see Flash Of…
Vishnu Sankaran
  • 669
  • 6
  • 20
8
votes
1 answer

Why are styles invisible, and style tags not re-appendable after using insertRule of CSSOM

If I've added styles with CSSOM using insertRule I've noticed two things. The added styles don't appear in the html while viewing in Firebug ever. The added styles don't work if the style tag is appended (ex: moved from head to body) to another…
Quentin Engles
  • 2,744
  • 1
  • 20
  • 33
7
votes
2 answers

Is the 'getPropertyValue' method required for retrieving CSS?

Could you tell me why we need to use the getPropertyValue method if we can use only the getComputedStyle one? For example, this will work, as far as I understand: var s = getComputedStyle(element, null).opacity; Which is equivalent to the…
El cero
  • 607
  • 5
  • 13
5
votes
1 answer

How can I create CSS variables with JavaScript?

I'm using :root to create some CSS variables. Is it possible to create them with JavaScript instead of CSS? Below is a simple example:
:root { --first-color: #000; --second-color: #666666; } #container { …
user17510301
5
votes
1 answer

Is color format specified in the spec for getComputedStyle?

I'm parsing a color string returned by getComputedStyle to get R, G, B, and A values from it. So far (in Chrome and Firefox), color values always seem to come back in rgb or rgba format which is easy to parse: const [, r, g, b, a] =…
Sandy Gifford
  • 7,219
  • 3
  • 35
  • 65
5
votes
0 answers

Chrome: DOMContentLoaded doesn't wait for CSSOM in deferred script tags?

In my understanding when using defer in a script tag which is placed right below a stylesheet, the browser waits for the stylesheet to load (CSSOM) before executing the script and firing DOMContentLoaded. (More about that) This works in Firefox but…
5
votes
1 answer

Is JavaScript execution deferred until CSSOM is built or not?

The answer to this question has been clear to me ever since I read/learned about CSSOM, until today. I can't seem to be able to find the initial article, but it explained quite clear, with examples, that JavaScript execution is deferred until CSSOM…
tao
  • 82,996
  • 16
  • 114
  • 150
4
votes
1 answer

Handling similar to ?

During investigation of advantages and disadvantages of attaching CSS with processing instruction, I came upon some issues. Suppose we have a simple XHTML document (which is delivered with application/xhtml+xml MIME type and viewed…
user6423602
4
votes
0 answers

scrollTop returns integer in chrome on high dpi devices: is there a way to get the non-rounded value?

Properties such as scrollTop or scrollLeft, as well as many other "old" (dhtml) properties now to-be-standardized in the CSSOM View module, still return integer rather than double (as specified in the draft) in high dpi devices. For example on such…
Wes
  • 3,978
  • 4
  • 24
  • 45
1
2 3 4 5