Skip to content

Instantly share code, notes, and snippets.

@Joozty
Created November 11, 2021 10:12
Show Gist options
  • Save Joozty/f7a35a8d9040868249217ac137e85473 to your computer and use it in GitHub Desktop.
Save Joozty/f7a35a8d9040868249217ac137e85473 to your computer and use it in GitHub Desktop.
.cssText property returns invalid CSS
<style>
.test1 {
--linear: linear-gradient(-90deg, #f0f0f0 0%, #f8f8f8 50%, #f0f0f0 100%);
background: var(--linear);
background-size: 400% 400%;
}
</style>
<style>
.test2 {
--linear: linear-gradient(-90deg, #f0f0f0 0%, #f8f8f8 50%, #f0f0f0 100%);
background: var(--linear);
}
</style>
<script>
// returns .test1 { --linear: linear-gradient(-90deg, #f0f0f0 0%, #f8f8f8 50%, #f0f0f0 100%); background-image: ; background-position-x: ; background-position-y: ; background-repeat-x: ; background-repeat-y: ; background-attachment: ; background-origin: ; background-clip: ; background-color: ; background-size: 400% 400%; }
console.log(document.styleSheets[0].cssRules[0].cssText)
// returns .test2 { --linear: linear-gradient(-90deg, #f0f0f0 0%, #f8f8f8 50%, #f0f0f0 100%); background: var(--linear); }
console.log(document.styleSheets[1].cssRules[0].cssText)
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment