diff options
Diffstat (limited to 'components/script/dom/htmlelement.rs')
-rw-r--r-- | components/script/dom/htmlelement.rs | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs index 32a979ad138..f41370386e9 100644 --- a/components/script/dom/htmlelement.rs +++ b/components/script/dom/htmlelement.rs @@ -645,13 +645,16 @@ impl HTMLElementMethods<crate::DomTypeHolder> for HTMLElement { Ok(internals) } - // FIXME: The nonce should be stored in an internal slot instead of an - // attribute (https://html.spec.whatwg.org/multipage/#cryptographicnonce) // https://html.spec.whatwg.org/multipage/#dom-noncedelement-nonce - make_getter!(Nonce, "nonce"); + fn Nonce(&self) -> DOMString { + self.as_element().nonce_value().into() + } // https://html.spec.whatwg.org/multipage/#dom-noncedelement-nonce - make_setter!(SetNonce, "nonce"); + fn SetNonce(&self, value: DOMString) { + self.as_element() + .update_nonce_internal_slot(value.to_string()) + } // https://html.spec.whatwg.org/multipage/#dom-fe-autofocus fn Autofocus(&self) -> bool { @@ -1138,6 +1141,15 @@ impl VirtualMethods for HTMLElement { }, } }, + (&local_name!("nonce"), mutation) => match mutation { + AttributeMutation::Set(_) => { + let nonce = &**attr.value(); + element.update_nonce_internal_slot(nonce.to_owned()); + }, + AttributeMutation::Removed => { + element.update_nonce_internal_slot("".to_owned()); + }, + }, _ => {}, } } |