mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Implement inner slot for cryptographic nonce (#36965)
Also update the `html/dom/reflection-metadata.html` test to handle the case where `nonce` does not reflect back to the attribute after an IDL change. Part of https://github.com/servo/servo/issues/4577 Fixes https://github.com/web-platform-tests/wpt/issues/43286 Signed-off-by: Tim van der Lippe <tvanderlippe@gmail.com>
This commit is contained in:
parent
3aff272e14
commit
a24fce3ae7
14 changed files with 132 additions and 98 deletions
|
@ -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());
|
||||
},
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue