Skip to content

Commit

Permalink
Add constructor, replace, and replaceSync methods to CssStyleSheet (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
ngryman committed Aug 30, 2023
1 parent 865923b commit 86fd961
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
* Add unstable bindings for the Prioritized Task Scheduling API.
[#3566](https://github.com/rustwasm/wasm-bindgen/pull/3566)

* Add bindings for `CssStyleSheet` constructor and `replace(_sync)` methods.
[#3573](https://github.com/rustwasm/wasm-bindgen/pull/3573)

* Add bindings for `CanvasTransform.setTransform(DOMMatrix2DInit)`.
[#3580](https://github.com/rustwasm/wasm-bindgen/pull/3580)

Expand Down
21 changes: 21 additions & 0 deletions crates/web-sys/src/features/gen_CssStyleSheet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ extern "C" {
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `CssRuleList`, `CssStyleSheet`*"]
pub fn css_rules(this: &CssStyleSheet) -> Result<CssRuleList, JsValue>;
#[wasm_bindgen(catch, constructor, js_class = "CSSStyleSheet")]
#[doc = "The `new CssStyleSheet(..)` constructor, creating a new instance of `CssStyleSheet`."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/CSSStyleSheet)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `CssStyleSheet`*"]
pub fn new() -> Result<CssStyleSheet, JsValue>;
# [wasm_bindgen (catch , method , structural , js_class = "CSSStyleSheet" , js_name = deleteRule)]
#[doc = "The `deleteRule()` method."]
#[doc = ""]
Expand All @@ -53,4 +60,18 @@ extern "C" {
rule: &str,
index: u32,
) -> Result<u32, JsValue>;
# [wasm_bindgen (method , structural , js_class = "CSSStyleSheet" , js_name = replace)]
#[doc = "The `replace()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/replace)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `CssStyleSheet`*"]
pub fn replace(this: &CssStyleSheet, text: &str) -> ::js_sys::Promise;
# [wasm_bindgen (catch , method , structural , js_class = "CSSStyleSheet" , js_name = replaceSync)]
#[doc = "The `replaceSync()` method."]
#[doc = ""]
#[doc = "[MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleSheet/replaceSync)"]
#[doc = ""]
#[doc = "*This API requires the following crate features to be activated: `CssStyleSheet`*"]
pub fn replace_sync(this: &CssStyleSheet, text: &str) -> Result<(), JsValue>;
}
6 changes: 6 additions & 0 deletions crates/web-sys/webidls/enabled/CSSStyleSheet.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ enum CSSStyleSheetParsingMode {
};

interface CSSStyleSheet : StyleSheet {
[Throws]
constructor();
[Pure]
readonly attribute CSSRule? ownerRule;
[Throws, NeedsSubjectPrincipal]
Expand All @@ -24,4 +26,8 @@ interface CSSStyleSheet : StyleSheet {
unsigned long insertRule(DOMString rule, optional unsigned long index = 0);
[Throws, NeedsSubjectPrincipal]
undefined deleteRule(unsigned long index);
[NewObject]
Promise<CSSStyleSheet> replace(USVString text);
[Throws]
undefined replaceSync(USVString text);
};

0 comments on commit 86fd961

Please sign in to comment.