Check whether an element is custom in the spec-compliant way (#35960)

* Check whether element is custom in spec-compliant way

Signed-off-by: Xiaocheng Hu <xiaochengh.work@gmail.com>

* Update tests

Signed-off-by: Xiaocheng Hu <xiaochengh.work@gmail.com>

---------

Signed-off-by: Xiaocheng Hu <xiaochengh.work@gmail.com>
This commit is contained in:
Xiaocheng Hu 2025-03-14 02:03:57 +08:00 committed by GitHub
parent ea35353e9a
commit 62d6759106
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 71 additions and 13 deletions

View file

@ -422,7 +422,8 @@ impl Node {
pub(crate) fn as_custom_element(&self) -> Option<DomRoot<Element>> {
self.downcast::<Element>().and_then(|element| {
if element.get_custom_element_definition().is_some() {
if element.is_custom() {
assert!(element.get_custom_element_definition().is_some());
Some(DomRoot::from_ref(element))
} else {
None
@ -2334,7 +2335,7 @@ impl Node {
.filter_map(DomRoot::downcast::<Element>)
{
// Step 7.7.2, whatwg/dom#833
if descendant.get_custom_element_definition().is_some() {
if descendant.is_custom() {
if descendant.is_connected() {
ScriptThread::enqueue_callback_reaction(
&descendant,