Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Wülker <[email protected]>
  • Loading branch information
simonwuelker committed Jan 21, 2025
1 parent 31866e3 commit 9c2e97d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
13 changes: 9 additions & 4 deletions html5ever/src/tree_builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1392,11 +1392,13 @@ where
// template start tag's shadowrootmode is not in the none state
let is_shadow_root_mode = tag.attrs.iter().any(|attr| {
attr.name.local == local_name!("shadowrootmode")
&& (attr.value.to_string() == String::from("open") || attr.value.to_string() == String::from("close"))
&& (attr.value.to_string() == String::from("open")
|| attr.value.to_string() == String::from("close"))
});

// Check if intended_parent's document allows declarative shadow roots
let allow_declarative_shadow_roots = self.sink.allow_declarative_shadow_roots(&intended_parent);
let allow_declarative_shadow_roots =
self.sink.allow_declarative_shadow_roots(&intended_parent);

// the adjusted current node is not the topmost element in the stack of open elements
let adjusted_current_node_not_topmost = match self.open_elems.borrow().first() {
Expand All @@ -1412,11 +1414,14 @@ where
None => true,
};

return is_shadow_root_mode && allow_declarative_shadow_roots && adjusted_current_node_not_topmost;
return is_shadow_root_mode
&& allow_declarative_shadow_roots
&& adjusted_current_node_not_topmost;
}

fn attach_declarative_shadow(&self, tag: &Tag) -> Result<(), String> {
self.sink.attach_declarative_shadow(self.open_elems.borrow().last().unwrap(), tag.attrs.clone())
self.sink
.attach_declarative_shadow(self.open_elems.borrow().last().unwrap(), tag.attrs.clone())
}

fn create_formatting_element_for(&self, tag: Tag) -> Handle {
Expand Down
6 changes: 4 additions & 2 deletions markup5ever/interface/tree_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ pub trait TreeSink {
}

fn allow_declarative_shadow_roots(&self, _intended_parent: &Self::Handle) -> bool {
return true;
true
}

/// Attach declarative shadow
Expand All @@ -271,7 +271,9 @@ pub trait TreeSink {
_location: &Self::Handle,
_attrs: Vec<Attribute>,
) -> Result<(), String> {
Err(String::from("No implementation for attach_declarative_shadow"))
Err(String::from(
"No implementation for attach_declarative_shadow",
))
}
}

Expand Down

0 comments on commit 9c2e97d

Please sign in to comment.