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/

52 questions
27
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
  • 5,979
  • 8
  • 54
  • 117
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,012
  • 5
  • 54
  • 86
10
votes
1 answer

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…
9
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
  • 163,768
  • 59
  • 261
  • 366
8
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,355
  • 1
  • 12
  • 21
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,352
  • 1
  • 16
  • 31
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
  • 553
  • 4
  • 13
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
  • 59,850
  • 12
  • 84
  • 110
4
votes
3 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
  • 559
  • 3
  • 18
4
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…
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…
3
votes
2 answers

Listening for changes made to CSS classes in Chrome Devtools

I want to check if someone has modified the CSS rules of an element through Chrome Devtools. Normally MutationObserver would suffice for this, however, MutationObserver is only able to observe changes to the inline style attribute, and cannot detect…
3
votes
1 answer

Maintaining Vertical Rhythm on arbitrary images

I would like to be able to maintain vertical rhythm on a page that contains images of unknown heights. I found this but am using vanilla-js rather than jquery so a jquery plugin is out of the question. The other answer requires that the baseline be…
3
votes
2 answers

Snapshot All CSS on a website

I am trying to write a tool that runs in the browser (in Javascript) and can take a "snapshot" of the state of a website at a single point in time. It strips out script tags, inlines images and fonts to data urls, and inlines CSS. The CSS part is…
1
2 3 4