Skip to content

Commit 4e9e53e

Browse files
Update comments according to the spec
1 parent e94e8be commit 4e9e53e

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

html5ever/src/tree_builder/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -1377,7 +1377,7 @@ where
13771377
self.insert_element(Push, ns!(html), name, vec![])
13781378
}
13791379

1380-
// https://html.spec.whatwg.org/multipage/parsing.html#insert-an-element-at-the-adjusted-insertion-location
1380+
/// https://html.spec.whatwg.org/multipage/parsing.html#insert-an-element-at-the-adjusted-insertion-location
13811381
fn insert_foreign_element(
13821382
&self,
13831383
tag: Tag,
@@ -1398,8 +1398,8 @@ where
13981398
}
13991399
//§ END
14001400

1401-
// https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inhead
1402-
// A start tag whose tag name is "template"
1401+
/// https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inhead
1402+
/// A start tag whose tag name is "template"
14031403
fn should_attach_declarative_shadow(&self, tag: &Tag) -> bool {
14041404
let adjusted_insertion_location = self.appropriate_place_for_insertion(None);
14051405

@@ -1414,7 +1414,7 @@ where
14141414
// template start tag's shadowrootmode is not in the none state
14151415
let is_shadow_root_mode = tag.attrs.iter().any(|attr| {
14161416
attr.name.local == local_name!("shadowrootmode")
1417-
&& (attr.value.to_string() == *"open" || attr.value.to_string() == *"closed")
1417+
&& (attr.value.as_ref() == "open" || attr.value.as_ref() == "closed")
14181418
});
14191419

14201420
// Check if intended_parent's document allows declarative shadow roots
@@ -1438,8 +1438,8 @@ where
14381438
is_shadow_root_mode && allow_declarative_shadow_roots && adjusted_current_node_not_topmost
14391439
}
14401440

1441-
// https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inhead
1442-
// A start tag whose tag name is "template"
1441+
/// https://html.spec.whatwg.org/multipage/parsing.html#parsing-main-inhead
1442+
/// A start tag whose tag name is "template"
14431443
fn attach_declarative_shadow(
14441444
&self,
14451445
tag: &Tag,

html5ever/src/tree_builder/rules.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -162,18 +162,20 @@ where
162162
if (self.should_attach_declarative_shadow(&tag)) {
163163
// Attach shadow path
164164

165-
// Step 1.
165+
// Step 1. Let declarative shadow host element be adjusted current node.
166166
let mut shadow_host = self.open_elems.borrow().last().unwrap().clone();
167167
if self.is_fragment() && self.open_elems.borrow().len() == 1 {
168168
shadow_host = self.context_elem.borrow().clone().unwrap();
169169
}
170170

171-
// Step 2.
171+
// Step 2. Let template be the result of insert a foreign element for template start tag, with HTML namespace and true.
172172
let template = self.insert_foreign_element(tag.clone(), ns!(html), true);
173173

174174
// Step 3 - 8.
175+
// Attach a shadow root with declarative shadow host element, mode, clonable, serializable, delegatesFocus, and "named".
175176
if self.attach_declarative_shadow(&tag, &shadow_host, &template).is_err() {
176-
// Step 8.1.1.
177+
// Step 8.1.1. Insert an element at the adjusted insertion location with template.
178+
// Pop the current template element created in step 2 first.
177179
self.pop();
178180
self.insert_element_for(tag);
179181
}

0 commit comments

Comments
 (0)