script: Don't re-parse link relations when binding element to tree (#44139)

The parsed relations of a element don't depend on its position in the
DOM tree at all, so this does nothing.

Testing: This should not change observable behaviour, WPT should catch
regressions

---------

Signed-off-by: Simon Wülker <simon.wuelker@arcor.de>
This commit is contained in:
Simon Wülker
2026-04-12 23:49:31 +02:00
committed by GitHub
parent 7c5df4e45b
commit 25d3f4b7a9
4 changed files with 23 additions and 50 deletions

View File

@@ -77,9 +77,7 @@ use crate::dom::html::htmlselectelement::HTMLSelectElement;
use crate::dom::html::htmltextareaelement::HTMLTextAreaElement;
use crate::dom::html::input_element::HTMLInputElement;
use crate::dom::input_element::input_type::InputType;
use crate::dom::node::{
BindContext, Node, NodeFlags, NodeTraits, UnbindContext, VecPreOrderInsertionHelper,
};
use crate::dom::node::{Node, NodeFlags, NodeTraits, UnbindContext, VecPreOrderInsertionHelper};
use crate::dom::nodelist::{NodeList, RadioListMode};
use crate::dom::radionodelist::RadioNodeList;
use crate::dom::submitevent::SubmitEvent;
@@ -91,6 +89,7 @@ use crate::navigation::navigate;
use crate::script_runtime::CanGc;
use crate::script_thread::ScriptThread;
/// <https://html.spec.whatwg.org/multipage/#the-form-element>
#[dom_struct]
pub(crate) struct HTMLFormElement {
htmlelement: HTMLElement,
@@ -114,6 +113,7 @@ pub(crate) struct HTMLFormElement {
/// <https://html.spec.whatwg.org/multipage/#planned-navigation>
planned_navigation: Cell<usize>,
/// <https://html.spec.whatwg.org/multipage/#attr-form-rel>
#[no_trace]
relations: Cell<LinkRelations>,
}
@@ -1922,15 +1922,6 @@ impl VirtualMethods for HTMLFormElement {
_ => {},
}
}
fn bind_to_tree(&self, cx: &mut JSContext, context: &BindContext) {
if let Some(s) = self.super_type() {
s.bind_to_tree(cx, context);
}
self.relations
.set(LinkRelations::for_element(self.upcast()));
}
}
pub(crate) trait FormControlElementHelpers {