Namespace: SpawnDev.SpawnJS.JSObjects
Inherits: SpawnJSObject
Source: JSObjects/StyleSheetList.cs
MDN Reference: StyleSheetList on MDN
The StyleSheetList interface represents a list of CSSStyleSheet objects. An instance of this object can be returned by Document.styleSheets. https://developer.mozilla.org/en-US/docs/Web/API/StyleSheetList
| Signature | Description |
|---|---|
StyleSheetList(SpawnJSObjectReference _ref) |
Deserialization constructor |
| Property | Type | Access | Description |
|---|---|---|---|
Length |
int |
get | The number of nodes in the StyleSheetList. |
| Method | Return Type | Description |
|---|---|---|
Item(int index) |
CSSStyleSheet |
Returns an item in the list by its index, or null if the index is out-of-bounds. |
ToList() |
List<CSSStyleSheet> |
Returns as a list |
ToArray() |
CSSStyleSheet[] |
Returns as an array |
SpawnDev.SpawnJS Mapping Note: The JavaScript examples below show the standard Web API usage. In SpawnDev.SpawnJS, the same API is available with C# conventions:
- Properties and methods use PascalCase (e.g.,
readyStatebecomesReadyState)- Events use ActionEvent with
+=/-=(e.g.,addEventListener("click", fn)becomesOnClick += handler)- Async methods return
Task<T>instead ofPromise<T>- Objects should be disposed with
usingstatements- Access via
JS.Get<StyleSheetList>(...)or constructornew StyleSheetList(...)
for (const styleSheet of document.styleSheets) {
console.log(styleSheet); // A CSSStyleSheet object
}const allCSS = [...document.styleSheets]
.map((styleSheet) => {
try {
return [...styleSheet.cssRules].map((rule) => rule.cssText).join("");
} catch (e) {
console.log(
"Access to stylesheet %s is denied. Ignoring…",
styleSheet.href,
);
return undefined;
}
})
.filter(Boolean)
.join("\n");