@@ -151,7 +151,7 @@ fn create_html_element(
151151 // local name set to localName, custom element state set to "undefined",
152152 // custom element definition set to null, is value set to is,
153153 // and node document set to document.
154- let element = create_native_html_element ( name, prefix, document, creator, proto) ;
154+ let element = create_native_html_element ( name, prefix, document, creator, proto, false ) ;
155155 element. set_is ( definition. name . clone ( ) ) ;
156156 element. set_custom_element_state ( CustomElementState :: Undefined ) ;
157157 match mode {
@@ -236,7 +236,8 @@ fn create_html_element(
236236 // namespace set to namespace, namespace prefix set to prefix, local name set to localName,
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.
239- let result = create_native_html_element ( name. clone ( ) , prefix, document, creator, proto) ;
239+ 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) ;
240241 // Step 5.3. If namespace is the HTML namespace, and either localName is a valid custom element name or
241242 // is is non-null, then set result’s custom element state to "undefined".
242243 match is {
@@ -247,8 +248,6 @@ fn create_html_element(
247248 None => {
248249 if is_valid_custom_element_name ( & name. local ) {
249250 result. set_custom_element_state ( CustomElementState :: Undefined ) ;
250- } else {
251- result. set_custom_element_state ( CustomElementState :: Uncustomized ) ;
252251 }
253252 } ,
254253 } ;
@@ -263,6 +262,7 @@ pub(crate) fn create_native_html_element(
263262 document : & Document ,
264263 creator : ElementCreator ,
265264 proto : Option < HandleObject > ,
265+ defined : bool ,
266266) -> DomRoot < Element > {
267267 assert_eq ! ( name. ns, ns!( html) ) ;
268268
@@ -318,7 +318,14 @@ pub(crate) fn create_native_html_element(
318318 local_name ! ( "dfn" ) => make ! ( HTMLElement ) ,
319319 local_name ! ( "dialog" ) => make ! ( HTMLDialogElement ) ,
320320 local_name ! ( "dir" ) => make ! ( HTMLDirectoryElement ) ,
321- local_name ! ( "div" ) => make ! ( HTMLDivElement ) ,
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+ } ,
322329 local_name ! ( "dl" ) => make ! ( HTMLDListElement ) ,
323330 local_name ! ( "dt" ) => make ! ( HTMLElement ) ,
324331 local_name ! ( "em" ) => make ! ( HTMLElement ) ,
0 commit comments