@@ -237,7 +237,8 @@ fn create_html_element(
237237 // custom element state set to "uncustomized", custom element definition set to null,
238238 // is value set to is, and node document set to document.
239239 let is_builtin = is. is_none ( ) && !is_valid_custom_element_name ( & name. local ) ;
240- let result = create_native_html_element ( name. clone ( ) , prefix, document, creator, proto, is_builtin) ;
240+ let result =
241+ create_native_html_element ( name. clone ( ) , prefix, document, creator, proto, is_builtin) ;
241242 // Step 5.3. If namespace is the HTML namespace, and either localName is a valid custom element name or
242243 // is is non-null, then set result’s custom element state to "undefined".
243244 match is {
@@ -280,7 +281,7 @@ pub(crate) fn create_native_html_element(
280281 // This is a big match, and the IDs for inline-interned atoms are not very structured.
281282 // Perhaps we should build a perfect hash from those IDs instead.
282283 // https://html.spec.whatwg.org/multipage/#elements-in-the-dom
283- match name. local {
284+ let element : DomRoot < Element > = match name. local {
284285 local_name ! ( "a" ) => make ! ( HTMLAnchorElement ) ,
285286 local_name ! ( "abbr" ) => make ! ( HTMLElement ) ,
286287 local_name ! ( "acronym" ) => make ! ( HTMLElement ) ,
@@ -318,14 +319,7 @@ pub(crate) fn create_native_html_element(
318319 local_name ! ( "dfn" ) => make ! ( HTMLElement ) ,
319320 local_name ! ( "dialog" ) => make ! ( HTMLDialogElement ) ,
320321 local_name ! ( "dir" ) => make ! ( HTMLDirectoryElement ) ,
321- local_name ! ( "div" ) => {
322- let obj = if defined {
323- HTMLDivElement :: new_defined ( name. local , prefix, document, proto, CanGc :: note ( ) )
324- } else {
325- HTMLDivElement :: new ( name. local , prefix, document, proto, CanGc :: note ( ) )
326- } ;
327- DomRoot :: upcast ( obj)
328- } ,
322+ local_name ! ( "div" ) => make ! ( HTMLDivElement ) ,
329323 local_name ! ( "dl" ) => make ! ( HTMLDListElement ) ,
330324 local_name ! ( "dt" ) => make ! ( HTMLElement ) ,
331325 local_name ! ( "em" ) => make ! ( HTMLElement ) ,
@@ -435,7 +429,13 @@ pub(crate) fn create_native_html_element(
435429 local_name ! ( "xmp" ) => make ! ( HTMLPreElement ) ,
436430 _ if is_valid_custom_element_name ( & name. local ) => make ! ( HTMLElement ) ,
437431 _ => make ! ( HTMLUnknownElement ) ,
432+ } ;
433+
434+ if defined {
435+ element. force_defined ( ) ;
438436 }
437+
438+ element
439439}
440440
441441pub ( crate ) fn create_element (
0 commit comments