As per this the style tag can be disabled with disabled
attribute. I tried the below:
<head>
<style>body { color: black; }</style>
<style disabled>body {color: red; }</style>
</head>
<body>
Hello World !!
</body>
Both Chrome and Firefox does not respect that disabled
attribute and use the red color. IE 11 works correctly (shows black text).
Question: How to add internal style nodes in disabled state (in JS)?
Context:
I am dynamically loading a css file content as a style node, to do some rule-processing with document.sytleSheets.cssRules
etc. I do not want the current page styles to be affected by the presence of this temporary loaded style.
Setting document.sytleSheets[].disabled
works, but there is a lag between node insertion and the disabled state.
Tried using new DOMParser().parseFromString(cssFileContent, "text/html")
, which works (completely invisible) fine in loading the html content, but does not initialize the document.sytleSheets