diff --git a/html5ever/src/tree_builder/mod.rs b/html5ever/src/tree_builder/mod.rs
index 348c211d..b6d5a039 100644
--- a/html5ever/src/tree_builder/mod.rs
+++ b/html5ever/src/tree_builder/mod.rs
@@ -1146,6 +1146,7 @@ where
n
}
+ /// Pop element until an element with the given name has been popped.
fn pop_until_named(&self, name: LocalName) -> usize {
self.pop_until(|p| *p.ns == ns!(html) && *p.local == name)
}
@@ -1231,16 +1232,6 @@ where
_ => continue,
};
match *name {
- local_name!("select") => {
- for ancestor in self.open_elems.borrow()[0..i].iter().rev() {
- if self.html_elem_named(ancestor, local_name!("template")) {
- return InSelect;
- } else if self.html_elem_named(ancestor, local_name!("table")) {
- return InSelectInTable;
- }
- }
- return InSelect;
- },
local_name!("td") | local_name!("th") => {
if !last {
return InCell;
diff --git a/html5ever/src/tree_builder/rules.rs b/html5ever/src/tree_builder/rules.rs
index 9bce3570..b8c5d629 100644
--- a/html5ever/src/tree_builder/rules.rs
+++ b/html5ever/src/tree_builder/rules.rs
@@ -624,6 +624,13 @@ where
tag @
=> {
self.close_p_element_in_button_scope();
+ if self.in_scope_named(default_scope, local_name!("select")) {
+ self.generate_implied_end_except(local_name!("optgroup"));
+ if self.in_scope_named(default_scope, local_name!("option")) {
+ self.sink.parse_error(Borrowed("hr in option"));
+ }
+ }
+
self.insert_and_pop_element_for(tag);
self.frameset_ok.set(false);
DoneAckSelfClosing
@@ -662,24 +669,48 @@ where
//