Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add constructor, replace, and replaceSync methods to CssStyleSheet #3573

Merged
merged 6 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(DOMString text);
[Throws]
undefined replaceSync(DOMString text);
ngryman marked this conversation as resolved.
Show resolved Hide resolved
};