aboutsummaryrefslogtreecommitdiffstats
path: root/components/script
diff options
context:
space:
mode:
Diffstat (limited to 'components/script')
-rw-r--r--components/script/dom/customelementregistry.rs3
-rw-r--r--components/script/dom/htmlelement.rs10
2 files changed, 13 insertions, 0 deletions
diff --git a/components/script/dom/customelementregistry.rs b/components/script/dom/customelementregistry.rs
index bfd0622dbfb..68186da108c 100644
--- a/components/script/dom/customelementregistry.rs
+++ b/components/script/dom/customelementregistry.rs
@@ -58,6 +58,7 @@ pub(crate) enum CustomElementState {
Failed,
#[default]
Uncustomized,
+ Precustomized,
Custom,
}
@@ -924,6 +925,8 @@ fn run_upgrade_constructor(
let _ac = JSAutoRealm::new(*cx, constructor.callback());
let args = HandleValueArray::empty();
// Step 8.2. Set element's custom element state to "precustomized".
+ element.set_custom_element_state(CustomElementState::Precustomized);
+
if unsafe {
!Construct1(
*cx,
diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs
index 346b15ef009..6c8a29c4f22 100644
--- a/components/script/dom/htmlelement.rs
+++ b/components/script/dom/htmlelement.rs
@@ -13,6 +13,7 @@ use script_layout_interface::QueryMsg;
use style::attr::AttrValue;
use style_dom::ElementState;
+use super::customelementregistry::CustomElementState;
use crate::dom::activation::Activatable;
use crate::dom::attr::Attr;
use crate::dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterData_Binding::CharacterDataMethods;
@@ -618,6 +619,15 @@ impl HTMLElementMethods<crate::DomTypeHolder> for HTMLElement {
return Err(Error::NotSupported);
}
+ // Step 6: If this's custom element state is not "precustomized" or "custom",
+ // then throw a "NotSupportedError" DOMException.
+ if !matches!(
+ element.get_custom_element_state(),
+ CustomElementState::Precustomized | CustomElementState::Custom
+ ) {
+ return Err(Error::NotSupported);
+ }
+
if self.is_form_associated_custom_element() {
element.init_state_for_internals();
}