mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
style: Simplify some attr() parsing code.
This commit is contained in:
parent
d6e703a9e9
commit
26ef0f6178
1 changed files with 20 additions and 19 deletions
|
@ -1425,12 +1425,15 @@ impl Attr {
|
||||||
let first = input.try(|i| i.expect_ident()).ok();
|
let first = input.try(|i| i.expect_ident()).ok();
|
||||||
if let Ok(token) = input.try(|i| i.next_including_whitespace()) {
|
if let Ok(token) = input.try(|i| i.next_including_whitespace()) {
|
||||||
match token {
|
match token {
|
||||||
Token::Delim('|') => {
|
Token::Delim('|') => {}
|
||||||
|
_ => return Err(()),
|
||||||
|
}
|
||||||
// must be followed by an ident
|
// must be followed by an ident
|
||||||
let second_token = match input.next_including_whitespace()? {
|
let second_token = match input.next_including_whitespace()? {
|
||||||
Token::Ident(second) => second,
|
Token::Ident(second) => second,
|
||||||
_ => return Err(()),
|
_ => return Err(()),
|
||||||
};
|
};
|
||||||
|
|
||||||
let ns_with_id = if let Some(ns) = first {
|
let ns_with_id = if let Some(ns) = first {
|
||||||
let ns: Namespace = ns.into();
|
let ns: Namespace = ns.into();
|
||||||
let id = get_id_for_namespace(&ns, context)?;
|
let id = get_id_for_namespace(&ns, context)?;
|
||||||
|
@ -1443,9 +1446,7 @@ impl Attr {
|
||||||
attribute: second_token.into_owned(),
|
attribute: second_token.into_owned(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
_ => return Err(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if let Some(first) = first {
|
if let Some(first) = first {
|
||||||
Ok(Attr {
|
Ok(Attr {
|
||||||
namespace: None,
|
namespace: None,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue