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.

HTMLStyleElement.sheet DOM definition

See original GitHub issue

TypeScript Version: 3.2.0-dev.201xxxxx

Search Terms: sheet

Code

using the DOM API

const style = document.querySelector('style');
const sheet = style.sheet;

Expected behavior:

sheet is returned as a StyleSheet, however ALL browsers do not return a StyleSheet class, they return a CSSStyleSheet class, so when you do something like sheet.insertRule it doesn’t exist in the type

Actual behavior:

style.sheet returns a StyleSheet class

Playground Link: https://www.typescriptlang.org/play/index.html#src=const style %3D document.querySelector(‘style’)%3B const sheet %3D style.sheet%3B sheet.insertRule(‘.hello {color%3A %23f00}’)%3B

Related Issues:

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
lifeiscontentcommented, Jun 11, 2019

@saschanaz any updates on this?

1reaction
SuryaElavazhagancommented, May 17, 2019

Is there any ways to get writable CSSStyleSheet object from the DOM?

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTMLStyleElement - Web APIs - MDN Web Docs
Chrome Edge HTMLStyleElement Full support. Chrome1. Toggle history Full support. Edge12. Togg... blocking. Experimental Full support. Chrome105. Toggle history Full support. Edge105. Tog... disabled Full support....
Read more >
Document Object Model StyleSheets - W3C
The StyleSheetList interface provides the abstraction of an ordered collection of style sheets. IDL Definition. // Introduced in DOM Level 2: interface ...
Read more >
HTMLStyleElement (Common DOM API)
Designed for use with one or more target media. See the media attribute definition in HTML 4.0. setMedia. void setMedia(String media) ...
Read more >
HTMLStyleElement
The HTMLStyleElement interface represents a style element. ... Document Object Model (DOM) Level 2 HTML Specification The definition of ...
Read more >
HTML DOM Element style Property - W3Schools
It does not contain any style properties set in the <head> section or in any external style sheets. Note 1. You cannot set...
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