mirror of
https://github.com/servo/servo
synced 2026-04-27 18:07:52 +02:00
script: Clean up attribute access a little bit in Element (#43064)
- Use modern Rust conveniences such as `unwrap_or_default` - Unabbreviate `attr` - Unify the lowercase ASCII name assertion and make it a debug assertion - Use `unreachable!` instead of panic - Expose two attribute getters that follow the behavior of two specification concepts and what we expect internally in Servo: - One that takes a namespace, but does not require lowercase attribute names. ([specification concept](https://dom.spec.whatwg.org/#concept-element-attributes-get-by-namespace>)) - One that does not take a namespace, but does require lowercase attribute names. ([specification concept](https://dom.spec.whatwg.org/#concept-element-attributes-get-by-name)) Testing: This should not really change behavior so should be covered by existing tests. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
@@ -10,7 +10,7 @@ use content_security_policy::sandboxing_directive::SandboxingFlagSet;
|
||||
use dom_struct::dom_struct;
|
||||
use encoding_rs::{Encoding, UTF_8};
|
||||
use headers::{ContentType, HeaderMapExt};
|
||||
use html5ever::{LocalName, Prefix, local_name, ns};
|
||||
use html5ever::{LocalName, Prefix, local_name};
|
||||
use http::Method;
|
||||
use js::context::JSContext;
|
||||
use js::rust::HandleObject;
|
||||
@@ -1043,7 +1043,7 @@ impl HTMLFormElement {
|
||||
// then set referrerPolicy to "no-referrer".
|
||||
// Note: both steps done below.
|
||||
let elem = self.upcast::<Element>();
|
||||
let referrer = match elem.get_attribute(&ns!(), &local_name!("rel")) {
|
||||
let referrer = match elem.get_attribute(&local_name!("rel")) {
|
||||
Some(ref link_types) if link_types.Value().contains("noreferrer") => {
|
||||
Referrer::NoReferrer
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user