Skip to content

Instantly share code, notes, and snippets.

@esprehn
Created February 18, 2016 01:50
Show Gist options
  • Save esprehn/48809824972fd695b54b to your computer and use it in GitHub Desktop.
Save esprehn/48809824972fd695b54b to your computer and use it in GitHub Desktop.
CSSStyleSheet API
dictionary CSSStyleSheetInit {
// TODO: Should also take a MediaList, but those have no constructor. When
// it does take those, it should make a copy so mutations to the list don't
// impact the sheet. This is for v2 of the API.
DOMString media = "";
DOMString title = "";
boolean alternate = false;
boolean disabled = false;
};
// When invoked parses the sheet using the current context document for
// state, that is quirks or standards mode, case conversion (html vs xml),
// url resolution, etc.
// TODO: Should we allow passing a different document in options?
[Constructor(DOMString text, CSSStyleSheetInit? options)]
partial interface CSSStyleSheet {
// Does a deep clone of all rules and the MediaList.
//
// Blink implementation note: Internally this just shares the
// StyleSheetContents and forces a copy on write for any mutations of the
// sheet.
CSSStyleSheet clone();
};
interface CSSStyleSheetSet {
// When adding a sheet the ownerNode of the sheet becomes the document or
// the ShadowRoot.
setlike<CSSStyleSheet>;
};
[NoInterfaceObject]
interface TreeScope {
CSSStyleSheetSet scopedSheets;
};
Document implements TreeScope;
ShadowRoot implements TreeScope;
// StyleSheet can have an ownerNode of a Document or a ShadowRoot.
partial interface StyleSheet {
readonly attribute (Element or ProcessingInstruction or Document or ShadowRoot)? ownerNode;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment