2020-01-18 09:38:21 +01:00
/*
2024-10-04 13:19:50 +02:00
* Copyright ( c ) 2018 - 2022 , Andreas Kling < andreas @ ladybird . org >
2023-03-29 23:46:18 +01:00
* Copyright ( c ) 2020 - 2023 , Luke Wilde < lukew @ serenityos . org >
2020-01-18 09:38:21 +01:00
*
2021-04-22 01:24:48 -07:00
* SPDX - License - Identifier : BSD - 2 - Clause
2020-01-18 09:38:21 +01:00
*/
2022-08-28 13:42:07 +02:00
# include <LibWeb/DOM/Document.h>
2020-03-07 10:32:51 +01:00
# include <LibWeb/DOM/ElementFactory.h>
2023-03-29 23:46:18 +01:00
# include <LibWeb/HTML/CustomElements/CustomElementDefinition.h>
2023-03-23 04:28:25 -04:00
# include <LibWeb/HTML/CustomElements/CustomElementName.h>
2020-07-26 15:08:16 +02:00
# include <LibWeb/HTML/HTMLAnchorElement.h>
2020-08-09 17:10:41 +01:00
# include <LibWeb/HTML/HTMLAreaElement.h>
# include <LibWeb/HTML/HTMLAudioElement.h>
2020-09-18 09:49:51 +02:00
# include <LibWeb/HTML/HTMLBRElement.h>
2020-08-09 17:10:41 +01:00
# include <LibWeb/HTML/HTMLBaseElement.h>
2020-07-26 15:08:16 +02:00
# include <LibWeb/HTML/HTMLBodyElement.h>
2020-08-09 17:10:41 +01:00
# include <LibWeb/HTML/HTMLButtonElement.h>
2020-07-26 15:08:16 +02:00
# include <LibWeb/HTML/HTMLCanvasElement.h>
2020-09-18 09:49:51 +02:00
# include <LibWeb/HTML/HTMLDListElement.h>
2020-08-09 17:10:41 +01:00
# include <LibWeb/HTML/HTMLDataElement.h>
# include <LibWeb/HTML/HTMLDataListElement.h>
# include <LibWeb/HTML/HTMLDetailsElement.h>
# include <LibWeb/HTML/HTMLDialogElement.h>
2020-11-12 04:16:41 +00:00
# include <LibWeb/HTML/HTMLDirectoryElement.h>
2020-08-09 17:10:41 +01:00
# include <LibWeb/HTML/HTMLDivElement.h>
# include <LibWeb/HTML/HTMLEmbedElement.h>
# include <LibWeb/HTML/HTMLFieldSetElement.h>
2020-07-26 15:08:16 +02:00
# include <LibWeb/HTML/HTMLFontElement.h>
# include <LibWeb/HTML/HTMLFormElement.h>
2020-08-09 17:10:41 +01:00
# include <LibWeb/HTML/HTMLFrameElement.h>
# include <LibWeb/HTML/HTMLFrameSetElement.h>
2020-07-26 15:08:16 +02:00
# include <LibWeb/HTML/HTMLHRElement.h>
# include <LibWeb/HTML/HTMLHeadElement.h>
# include <LibWeb/HTML/HTMLHeadingElement.h>
# include <LibWeb/HTML/HTMLHtmlElement.h>
# include <LibWeb/HTML/HTMLIFrameElement.h>
# include <LibWeb/HTML/HTMLImageElement.h>
# include <LibWeb/HTML/HTMLInputElement.h>
2020-09-18 09:49:51 +02:00
# include <LibWeb/HTML/HTMLLIElement.h>
2020-08-09 17:10:41 +01:00
# include <LibWeb/HTML/HTMLLabelElement.h>
# include <LibWeb/HTML/HTMLLegendElement.h>
2020-07-26 15:08:16 +02:00
# include <LibWeb/HTML/HTMLLinkElement.h>
2020-08-09 17:10:41 +01:00
# include <LibWeb/HTML/HTMLMapElement.h>
# include <LibWeb/HTML/HTMLMarqueeElement.h>
# include <LibWeb/HTML/HTMLMenuElement.h>
# include <LibWeb/HTML/HTMLMetaElement.h>
# include <LibWeb/HTML/HTMLMeterElement.h>
# include <LibWeb/HTML/HTMLModElement.h>
# include <LibWeb/HTML/HTMLOListElement.h>
2020-09-18 09:49:51 +02:00
# include <LibWeb/HTML/HTMLObjectElement.h>
2020-08-09 17:10:41 +01:00
# include <LibWeb/HTML/HTMLOptGroupElement.h>
# include <LibWeb/HTML/HTMLOptionElement.h>
# include <LibWeb/HTML/HTMLOutputElement.h>
# include <LibWeb/HTML/HTMLParagraphElement.h>
# include <LibWeb/HTML/HTMLParamElement.h>
# include <LibWeb/HTML/HTMLPictureElement.h>
# include <LibWeb/HTML/HTMLPreElement.h>
# include <LibWeb/HTML/HTMLProgressElement.h>
# include <LibWeb/HTML/HTMLQuoteElement.h>
2020-07-26 15:08:16 +02:00
# include <LibWeb/HTML/HTMLScriptElement.h>
2020-08-09 17:10:41 +01:00
# include <LibWeb/HTML/HTMLSelectElement.h>
# include <LibWeb/HTML/HTMLSlotElement.h>
# include <LibWeb/HTML/HTMLSourceElement.h>
# include <LibWeb/HTML/HTMLSpanElement.h>
2020-07-26 15:08:16 +02:00
# include <LibWeb/HTML/HTMLStyleElement.h>
2023-06-02 21:08:14 +02:00
# include <LibWeb/HTML/HTMLSummaryElement.h>
2020-08-09 17:10:41 +01:00
# include <LibWeb/HTML/HTMLTableCaptionElement.h>
2020-07-26 15:08:16 +02:00
# include <LibWeb/HTML/HTMLTableCellElement.h>
2020-08-09 17:10:41 +01:00
# include <LibWeb/HTML/HTMLTableColElement.h>
2020-07-26 15:08:16 +02:00
# include <LibWeb/HTML/HTMLTableElement.h>
# include <LibWeb/HTML/HTMLTableRowElement.h>
2020-08-09 17:10:41 +01:00
# include <LibWeb/HTML/HTMLTableSectionElement.h>
# include <LibWeb/HTML/HTMLTemplateElement.h>
2020-09-18 09:49:51 +02:00
# include <LibWeb/HTML/HTMLTextAreaElement.h>
2020-08-09 17:10:41 +01:00
# include <LibWeb/HTML/HTMLTimeElement.h>
2020-07-26 15:08:16 +02:00
# include <LibWeb/HTML/HTMLTitleElement.h>
2020-09-18 09:49:51 +02:00
# include <LibWeb/HTML/HTMLTrackElement.h>
2020-08-09 17:10:41 +01:00
# include <LibWeb/HTML/HTMLUListElement.h>
# include <LibWeb/HTML/HTMLUnknownElement.h>
# include <LibWeb/HTML/HTMLVideoElement.h>
2023-03-29 23:46:18 +01:00
# include <LibWeb/HTML/Scripting/ExceptionReporter.h>
2025-02-02 14:47:12 +00:00
# include <LibWeb/HTML/WindowOrWorkerGlobalScope.h>
2023-10-01 20:07:44 +13:00
# include <LibWeb/Infra/Strings.h>
2023-07-05 20:25:52 -05:00
# include <LibWeb/MathML/MathMLElement.h>
# include <LibWeb/MathML/TagNames.h>
2023-03-29 23:46:18 +01:00
# include <LibWeb/Namespace.h>
2024-06-23 17:05:47 +02:00
# include <LibWeb/SVG/SVGAElement.h>
2022-02-11 16:14:58 +00:00
# include <LibWeb/SVG/SVGCircleElement.h>
2022-04-10 19:05:12 +02:00
# include <LibWeb/SVG/SVGClipPathElement.h>
2022-04-11 16:59:03 +02:00
# include <LibWeb/SVG/SVGDefsElement.h>
2024-04-15 18:43:01 +01:00
# include <LibWeb/SVG/SVGDescElement.h>
2022-02-11 16:45:59 +00:00
# include <LibWeb/SVG/SVGEllipseElement.h>
2025-07-04 20:55:08 +02:00
# include <LibWeb/SVG/SVGFEBlendElement.h>
2025-08-06 13:27:50 +01:00
# include <LibWeb/SVG/SVGFECompositeElement.h>
2025-07-06 21:48:55 +02:00
# include <LibWeb/SVG/SVGFEFloodElement.h>
2025-07-04 21:08:28 +02:00
# include <LibWeb/SVG/SVGFEGaussianBlurElement.h>
2025-08-06 22:52:29 +01:00
# include <LibWeb/SVG/SVGFEImageElement.h>
2025-08-06 16:29:28 +02:00
# include <LibWeb/SVG/SVGFEMergeElement.h>
# include <LibWeb/SVG/SVGFEMergeNodeElement.h>
2025-08-06 13:53:50 +02:00
# include <LibWeb/SVG/SVGFEOffsetElement.h>
2025-02-21 13:22:48 +01:00
# include <LibWeb/SVG/SVGFilterElement.h>
2022-11-10 13:49:26 +01:00
# include <LibWeb/SVG/SVGForeignObjectElement.h>
2021-09-18 00:04:19 +02:00
# include <LibWeb/SVG/SVGGElement.h>
2024-08-20 15:12:55 +01:00
# include <LibWeb/SVG/SVGImageElement.h>
2022-02-11 16:56:36 +00:00
# include <LibWeb/SVG/SVGLineElement.h>
2023-04-22 18:51:00 +01:00
# include <LibWeb/SVG/SVGLinearGradientElement.h>
2023-08-10 09:55:15 +02:00
# include <LibWeb/SVG/SVGMaskElement.h>
2024-08-16 17:27:32 +01:00
# include <LibWeb/SVG/SVGMetadataElement.h>
2020-07-23 09:44:42 -07:00
# include <LibWeb/SVG/SVGPathElement.h>
2022-02-11 17:36:05 +00:00
# include <LibWeb/SVG/SVGPolygonElement.h>
2022-02-11 17:28:24 +00:00
# include <LibWeb/SVG/SVGPolylineElement.h>
2023-05-02 23:11:58 +01:00
# include <LibWeb/SVG/SVGRadialGradientElement.h>
2022-02-11 15:52:42 +00:00
# include <LibWeb/SVG/SVGRectElement.h>
2020-07-23 09:44:42 -07:00
# include <LibWeb/SVG/SVGSVGElement.h>
2023-09-23 08:56:49 +12:00
# include <LibWeb/SVG/SVGScriptElement.h>
2023-04-20 18:51:00 +01:00
# include <LibWeb/SVG/SVGStopElement.h>
2023-06-08 17:48:33 +01:00
# include <LibWeb/SVG/SVGStyleElement.h>
2023-05-31 00:50:12 +01:00
# include <LibWeb/SVG/SVGSymbolElement.h>
2023-07-22 19:34:51 +01:00
# include <LibWeb/SVG/SVGTSpanElement.h>
2023-07-22 19:24:55 +01:00
# include <LibWeb/SVG/SVGTextElement.h>
2023-12-17 18:35:21 +00:00
# include <LibWeb/SVG/SVGTextPathElement.h>
2023-06-08 11:46:44 -04:00
# include <LibWeb/SVG/SVGTitleElement.h>
2023-05-30 21:23:52 +01:00
# include <LibWeb/SVG/SVGUseElement.h>
2025-07-12 14:26:50 +01:00
# include <LibWeb/SVG/SVGViewElement.h>
2020-07-23 09:44:42 -07:00
# include <LibWeb/SVG/TagNames.h>
2023-03-29 23:46:18 +01:00
# include <LibWeb/WebIDL/AbstractOperations.h>
2019-10-12 13:02:38 +02:00
2020-07-26 19:37:56 +02:00
namespace Web : : DOM {
2020-03-07 10:27:02 +01:00
2023-10-01 20:07:44 +13:00
ErrorOr < FixedArray < FlyString > > valid_local_names_for_given_html_element_interface ( StringView html_element_interface_name )
2019-10-12 13:02:38 +02:00
{
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLAnchorElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : a } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLAreaElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : area } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLAudioElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : audio } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLBaseElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : base } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLBodyElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : body } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLBRElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : br } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLButtonElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : button } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLCanvasElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : canvas } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLDataElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : data } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLDataListElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : datalist } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLDetailsElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : details } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLDialogElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : dialog } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLDirectoryElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : dir } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLDivElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : div } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLDListElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : dl } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLEmbedElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : embed } ) ;
2024-11-26 13:12:50 +01:00
if ( html_element_interface_name = = " HTMLFieldSetElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : fieldset } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLFontElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : font } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLFormElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : form } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLFrameElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : frame } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLFrameSetElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : frameset } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLHeadElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : head } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLHeadingElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : h1 , HTML : : TagNames : : h2 , HTML : : TagNames : : h3 , HTML : : TagNames : : h4 , HTML : : TagNames : : h5 , HTML : : TagNames : : h6 } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLHRElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : hr } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLHtmlElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : html } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLIFrameElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : iframe } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLImageElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : img } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLInputElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : input } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLLabelElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : label } ) ;
2025-02-02 14:44:17 +00:00
if ( html_element_interface_name = = " HTMLLegendElement " sv )
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : legend } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLLIElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : li } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLLinkElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : link } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLMapElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : map } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLMarqueeElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : marquee } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLMenuElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : menu } ) ;
2024-11-26 13:12:50 +01:00
if ( html_element_interface_name = = " HTMLMetaElement " sv )
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : meta } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLMeterElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : meter } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLModElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : ins , HTML : : TagNames : : del } ) ;
2024-11-26 13:12:50 +01:00
if ( html_element_interface_name = = " HTMLOListElement " sv )
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : ol } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLObjectElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : object } ) ;
2024-11-26 13:12:50 +01:00
if ( html_element_interface_name = = " HTMLOptGroupElement " sv )
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : optgroup } ) ;
2025-02-02 14:44:17 +00:00
if ( html_element_interface_name = = " HTMLOptionElement " sv )
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : option } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLOutputElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : output } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLParagraphElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : p } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLParamElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : param } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLPictureElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : picture } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLPreElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : pre , HTML : : TagNames : : listing , HTML : : TagNames : : xmp } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLProgressElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : progress } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLQuoteElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : blockquote , HTML : : TagNames : : q } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLScriptElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : script } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLSelectElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : select } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLSlotElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : slot } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLSourceElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : source } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLSpanElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : span } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLStyleElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : style } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLTableCaptionElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : caption } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLTableCellElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : td , HTML : : TagNames : : th } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLTableColElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : colgroup , HTML : : TagNames : : col } ) ;
2025-02-02 14:44:17 +00:00
if ( html_element_interface_name = = " HTMLTableRowElement " sv )
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : tr } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLTableElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : table } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLTableSectionElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : tbody , HTML : : TagNames : : thead , HTML : : TagNames : : tfoot } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLTemplateElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : template_ } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLTextAreaElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : textarea } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLTimeElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : time } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLTitleElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : title } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLTrackElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : track } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLUListElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : ul } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLVideoElement " sv )
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : video } ) ;
2023-03-29 23:46:18 +01:00
if ( html_element_interface_name = = " HTMLElement " sv )
2024-11-19 20:03:15 +01:00
return FixedArray < FlyString > : : create ( { HTML : : TagNames : : article , HTML : : TagNames : : search , HTML : : TagNames : : section , HTML : : TagNames : : nav , HTML : : TagNames : : aside , HTML : : TagNames : : hgroup , HTML : : TagNames : : header , HTML : : TagNames : : footer , HTML : : TagNames : : address , HTML : : TagNames : : dt , HTML : : TagNames : : dd , HTML : : TagNames : : figure , HTML : : TagNames : : figcaption , HTML : : TagNames : : main , HTML : : TagNames : : em , HTML : : TagNames : : strong , HTML : : TagNames : : small , HTML : : TagNames : : s , HTML : : TagNames : : cite , HTML : : TagNames : : dfn , HTML : : TagNames : : abbr , HTML : : TagNames : : ruby , HTML : : TagNames : : rt , HTML : : TagNames : : rp , HTML : : TagNames : : code , HTML : : TagNames : : var , HTML : : TagNames : : samp , HTML : : TagNames : : kbd , HTML : : TagNames : : sub , HTML : : TagNames : : sup , HTML : : TagNames : : i , HTML : : TagNames : : b , HTML : : TagNames : : u , HTML : : TagNames : : mark , HTML : : TagNames : : bdi , HTML : : TagNames : : bdo , HTML : : TagNames : : wbr , HTML : : TagNames : : summary , HTML : : TagNames : : noscript , HTML : : TagNames : : acronym , HTML : : TagNames : : basefont , HTML : : TagNames : : big , HTML : : TagNames : : center , HTML : : TagNames : : nobr , HTML : : TagNames : : noembed , HTML : : TagNames : : noframes , HTML : : TagNames : : plaintext , HTML : : TagNames : : rb , HTML : : TagNames : : rtc , HTML : : TagNames : : strike , HTML : : TagNames : : tt } ) ;
2023-10-01 20:07:44 +13:00
return FixedArray < FlyString > : : create ( { } ) ;
2023-03-29 23:46:18 +01:00
}
2022-02-25 21:29:12 +01:00
2023-03-29 23:46:18 +01:00
// https://html.spec.whatwg.org/multipage/dom.html#elements-in-the-dom%3Aelement-interface
2023-10-01 20:07:44 +13:00
bool is_unknown_html_element ( FlyString const & tag_name )
2023-03-29 23:46:18 +01:00
{
// NOTE: This is intentionally case-sensitive.
2022-02-25 21:29:12 +01:00
2023-03-29 23:46:18 +01:00
// 1. If name is applet, bgsound, blink, isindex, keygen, multicol, nextid, or spacer, then return HTMLUnknownElement.
if ( tag_name . is_one_of ( HTML : : TagNames : : applet , HTML : : TagNames : : bgsound , HTML : : TagNames : : blink , HTML : : TagNames : : isindex , HTML : : TagNames : : keygen , HTML : : TagNames : : multicol , HTML : : TagNames : : nextid , HTML : : TagNames : : spacer ) )
return true ;
2022-03-02 10:55:16 +01:00
2024-12-27 18:47:33 -05:00
// 2. If name is acronym, basefont, big, center, nobr, noembed, noframes, plaintext, rb, rtc, strike, or tt, then return HTMLElement.
// 3. If name is listing or xmp, then return HTMLPreElement.
// 4. Otherwise, if this specification defines an interface appropriate for the element type corresponding to the local name name, then return that interface.
// 5. If other applicable specifications define an appropriate interface for name, then return the interface they define.
2025-01-11 14:07:41 -05:00
# define __ENUMERATE_HTML_TAG(name, tag) \
2023-03-29 23:46:18 +01:00
if ( tag_name = = HTML : : TagNames : : name ) \
return false ;
ENUMERATE_HTML_TAGS
# undef __ENUMERATE_HTML_TAG
// 6. If name is a valid custom element name, then return HTMLElement.
if ( HTML : : is_valid_custom_element_name ( tag_name ) )
return false ;
// 7. Return HTMLUnknownElement.
return true ;
}
2025-02-04 13:01:46 +01:00
// https://html.spec.whatwg.org/multipage/dom.html#elements-in-the-dom%3Aelement-interface
2024-11-15 04:01:23 +13:00
static GC : : Ref < Element > create_html_element ( JS : : Realm & realm , Document & document , QualifiedName qualified_name )
2023-03-29 23:46:18 +01:00
{
2024-07-24 23:55:15 +01:00
FlyString tag_name = qualified_name . local_name ( ) ;
2022-03-02 10:55:16 +01:00
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : a )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLAnchorElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : area )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLAreaElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : audio )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLAudioElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : base )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLBaseElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : body )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLBodyElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : br )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLBRElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : button )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLButtonElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : canvas )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLCanvasElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : data )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLDataElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : datalist )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLDataListElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : details )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLDetailsElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : dialog )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLDialogElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : dir )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLDirectoryElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : div )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLDivElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : dl )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLDListElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : embed )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLEmbedElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : fieldset )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLFieldSetElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : font )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLFontElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : form )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLFormElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : frame )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLFrameElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : frameset )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLFrameSetElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : head )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLHeadElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name . is_one_of ( HTML : : TagNames : : h1 , HTML : : TagNames : : h2 , HTML : : TagNames : : h3 , HTML : : TagNames : : h4 , HTML : : TagNames : : h5 , HTML : : TagNames : : h6 ) )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLHeadingElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : hr )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLHRElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : html )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLHtmlElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : iframe )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLIFrameElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : img )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLImageElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : input )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLInputElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : label )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLLabelElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : legend )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLLegendElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : li )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLLIElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : link )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLLinkElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : map )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLMapElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : marquee )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLMarqueeElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : menu )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLMenuElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : meta )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLMetaElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : meter )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLMeterElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name . is_one_of ( HTML : : TagNames : : ins , HTML : : TagNames : : del ) )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLModElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : object )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLObjectElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : ol )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLOListElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : optgroup )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLOptGroupElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : option )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLOptionElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : output )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLOutputElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : p )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLParagraphElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : param )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLParamElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : picture )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLPictureElement > ( document , move ( qualified_name ) ) ;
2020-08-09 17:10:41 +01:00
// NOTE: The obsolete elements "listing" and "xmp" are explicitly mapped to HTMLPreElement in the specification.
2024-07-24 23:55:15 +01:00
if ( tag_name . is_one_of ( HTML : : TagNames : : pre , HTML : : TagNames : : listing , HTML : : TagNames : : xmp ) )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLPreElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : progress )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLProgressElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name . is_one_of ( HTML : : TagNames : : blockquote , HTML : : TagNames : : q ) )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLQuoteElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : script )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLScriptElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : select )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLSelectElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : slot )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLSlotElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : source )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLSourceElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : span )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLSpanElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : style )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLStyleElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : summary )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLSummaryElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : caption )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLTableCaptionElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name . is_one_of ( Web : : HTML : : TagNames : : td , Web : : HTML : : TagNames : : th ) )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLTableCellElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name . is_one_of ( HTML : : TagNames : : colgroup , HTML : : TagNames : : col ) )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLTableColElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : table )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLTableElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : tr )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLTableRowElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name . is_one_of ( HTML : : TagNames : : tbody , HTML : : TagNames : : thead , HTML : : TagNames : : tfoot ) )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLTableSectionElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : template_ )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLTemplateElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : textarea )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLTextAreaElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : time )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLTimeElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : title )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLTitleElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : track )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLTrackElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : ul )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLUListElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name = = HTML : : TagNames : : video )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLVideoElement > ( document , move ( qualified_name ) ) ;
2024-07-24 23:55:15 +01:00
if ( tag_name . is_one_of (
2024-11-19 20:03:15 +01:00
HTML : : TagNames : : article , HTML : : TagNames : : search , HTML : : TagNames : : section , HTML : : TagNames : : nav , HTML : : TagNames : : aside , HTML : : TagNames : : hgroup , HTML : : TagNames : : header , HTML : : TagNames : : footer , HTML : : TagNames : : address , HTML : : TagNames : : dt , HTML : : TagNames : : dd , HTML : : TagNames : : figure , HTML : : TagNames : : figcaption , HTML : : TagNames : : main , HTML : : TagNames : : em , HTML : : TagNames : : strong , HTML : : TagNames : : small , HTML : : TagNames : : s , HTML : : TagNames : : cite , HTML : : TagNames : : dfn , HTML : : TagNames : : abbr , HTML : : TagNames : : ruby , HTML : : TagNames : : rt , HTML : : TagNames : : rp , HTML : : TagNames : : code , HTML : : TagNames : : var , HTML : : TagNames : : samp , HTML : : TagNames : : kbd , HTML : : TagNames : : sub , HTML : : TagNames : : sup , HTML : : TagNames : : i , HTML : : TagNames : : b , HTML : : TagNames : : u , HTML : : TagNames : : mark , HTML : : TagNames : : bdi , HTML : : TagNames : : bdo , HTML : : TagNames : : wbr , HTML : : TagNames : : noscript ,
2020-09-18 09:49:51 +02:00
// Obsolete
HTML : : TagNames : : acronym , HTML : : TagNames : : basefont , HTML : : TagNames : : big , HTML : : TagNames : : center , HTML : : TagNames : : nobr , HTML : : TagNames : : noembed , HTML : : TagNames : : noframes , HTML : : TagNames : : plaintext , HTML : : TagNames : : rb , HTML : : TagNames : : rtc , HTML : : TagNames : : strike , HTML : : TagNames : : tt ) )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLElement > ( document , move ( qualified_name ) ) ;
2023-03-29 23:46:18 +01:00
if ( HTML : : is_valid_custom_element_name ( qualified_name . local_name ( ) ) )
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLElement > ( document , move ( qualified_name ) ) ;
2023-03-29 23:46:18 +01:00
2024-11-14 05:50:17 +13:00
return realm . create < HTML : : HTMLUnknownElement > ( document , move ( qualified_name ) ) ;
2023-03-29 23:46:18 +01:00
}
2024-11-15 04:01:23 +13:00
static GC : : Ref < SVG : : SVGElement > create_svg_element ( JS : : Realm & realm , Document & document , QualifiedName qualified_name )
2023-03-29 23:46:18 +01:00
{
2023-10-08 14:17:34 +13:00
auto const & local_name = qualified_name . local_name ( ) ;
2023-03-29 23:46:18 +01:00
if ( local_name = = SVG : : TagNames : : svg )
2024-11-14 05:50:17 +13:00
return realm . create < SVG : : SVGSVGElement > ( document , move ( qualified_name ) ) ;
2022-04-10 19:05:12 +02:00
// FIXME: Support SVG's mixedCase tag names properly.
2023-03-29 23:46:18 +01:00
if ( local_name . equals_ignoring_ascii_case ( SVG : : TagNames : : clipPath ) )
2024-11-14 05:50:17 +13:00
return realm . create < SVG : : SVGClipPathElement > ( document , move ( qualified_name ) ) ;
2023-03-29 23:46:18 +01:00
if ( local_name = = SVG : : TagNames : : circle )
2024-11-14 05:50:17 +13:00
return realm . create < SVG : : SVGCircleElement > ( document , move ( qualified_name ) ) ;
2023-03-29 23:46:18 +01:00
if ( local_name . equals_ignoring_ascii_case ( SVG : : TagNames : : defs ) )
2024-11-14 05:50:17 +13:00
return realm . create < SVG : : SVGDefsElement > ( document , move ( qualified_name ) ) ;
2024-04-15 18:43:01 +01:00
if ( local_name = = SVG : : TagNames : : desc )
2024-11-14 05:50:17 +13:00
return realm . create < SVG : : SVGDescElement > ( document , move ( qualified_name ) ) ;
2023-03-29 23:46:18 +01:00
if ( local_name = = SVG : : TagNames : : ellipse )
2024-11-14 05:50:17 +13:00
return realm . create < SVG : : SVGEllipseElement > ( document , move ( qualified_name ) ) ;
2025-07-04 20:55:08 +02:00
if ( local_name = = SVG : : TagNames : : feBlend )
return realm . create < SVG : : SVGFEBlendElement > ( document , move ( qualified_name ) ) ;
2025-08-06 13:27:50 +01:00
if ( local_name = = SVG : : TagNames : : feComposite )
return realm . create < SVG : : SVGFECompositeElement > ( document , move ( qualified_name ) ) ;
2025-07-06 21:48:55 +02:00
if ( local_name = = SVG : : TagNames : : feFlood )
return realm . create < SVG : : SVGFEFloodElement > ( document , move ( qualified_name ) ) ;
2025-07-04 21:08:28 +02:00
if ( local_name = = SVG : : TagNames : : feGaussianBlur )
return realm . create < SVG : : SVGFEGaussianBlurElement > ( document , move ( qualified_name ) ) ;
2025-08-06 22:52:29 +01:00
if ( local_name = = SVG : : TagNames : : feImage )
return realm . create < SVG : : SVGFEImageElement > ( document , move ( qualified_name ) ) ;
2025-08-06 16:29:28 +02:00
if ( local_name = = SVG : : TagNames : : feMerge )
return realm . create < SVG : : SVGFEMergeElement > ( document , move ( qualified_name ) ) ;
if ( local_name = = SVG : : TagNames : : feMergeNode )
return realm . create < SVG : : SVGFEMergeNodeElement > ( document , move ( qualified_name ) ) ;
2025-08-06 13:53:50 +02:00
if ( local_name = = SVG : : TagNames : : feOffset )
return realm . create < SVG : : SVGFEOffsetElement > ( document , move ( qualified_name ) ) ;
2025-02-21 13:22:48 +01:00
if ( local_name = = SVG : : TagNames : : filter )
return realm . create < SVG : : SVGFilterElement > ( document , move ( qualified_name ) ) ;
2023-03-29 23:46:18 +01:00
if ( local_name . equals_ignoring_ascii_case ( SVG : : TagNames : : foreignObject ) )
2024-11-14 05:50:17 +13:00
return realm . create < SVG : : SVGForeignObjectElement > ( document , move ( qualified_name ) ) ;
2023-03-29 23:46:18 +01:00
if ( local_name = = SVG : : TagNames : : line )
2024-11-14 05:50:17 +13:00
return realm . create < SVG : : SVGLineElement > ( document , move ( qualified_name ) ) ;
2023-04-22 18:51:00 +01:00
if ( local_name = = SVG : : TagNames : : linearGradient )
2024-11-14 05:50:17 +13:00
return realm . create < SVG : : SVGLinearGradientElement > ( document , move ( qualified_name ) ) ;
2023-08-10 09:55:15 +02:00
if ( local_name = = SVG : : TagNames : : mask )
2024-11-14 05:50:17 +13:00
return realm . create < SVG : : SVGMaskElement > ( document , move ( qualified_name ) ) ;
2024-08-16 17:27:32 +01:00
if ( local_name = = SVG : : TagNames : : metadata )
2024-11-14 05:50:17 +13:00
return realm . create < SVG : : SVGMetadataElement > ( document , move ( qualified_name ) ) ;
2023-03-29 23:46:18 +01:00
if ( local_name = = SVG : : TagNames : : path )
2024-11-14 05:50:17 +13:00
return realm . create < SVG : : SVGPathElement > ( document , move ( qualified_name ) ) ;
2023-03-29 23:46:18 +01:00
if ( local_name = = SVG : : TagNames : : polygon )
2024-11-14 05:50:17 +13:00
return realm . create < SVG : : SVGPolygonElement > ( document , move ( qualified_name ) ) ;
2023-03-29 23:46:18 +01:00
if ( local_name = = SVG : : TagNames : : polyline )
2024-11-14 05:50:17 +13:00
return realm . create < SVG : : SVGPolylineElement > ( document , move ( qualified_name ) ) ;
2023-05-02 23:11:58 +01:00
if ( local_name = = SVG : : TagNames : : radialGradient )
2024-11-14 05:50:17 +13:00
return realm . create < SVG : : SVGRadialGradientElement > ( document , move ( qualified_name ) ) ;
2023-03-29 23:46:18 +01:00
if ( local_name = = SVG : : TagNames : : rect )
2024-11-14 05:50:17 +13:00
return realm . create < SVG : : SVGRectElement > ( document , move ( qualified_name ) ) ;
2023-03-29 23:46:18 +01:00
if ( local_name = = SVG : : TagNames : : g )
2024-11-14 05:50:17 +13:00
return realm . create < SVG : : SVGGElement > ( document , move ( qualified_name ) ) ;
2023-04-20 18:51:00 +01:00
if ( local_name = = SVG : : TagNames : : stop )
2024-11-14 05:50:17 +13:00
return realm . create < SVG : : SVGStopElement > ( document , move ( qualified_name ) ) ;
2023-06-08 17:48:33 +01:00
if ( local_name = = SVG : : TagNames : : style )
2024-11-14 05:50:17 +13:00
return realm . create < SVG : : SVGStyleElement > ( document , move ( qualified_name ) ) ;
2023-05-31 00:50:12 +01:00
if ( local_name = = SVG : : TagNames : : symbol )
2024-11-14 05:50:17 +13:00
return realm . create < SVG : : SVGSymbolElement > ( document , move ( qualified_name ) ) ;
2023-03-29 23:46:18 +01:00
if ( local_name = = SVG : : TagNames : : text )
2024-11-14 05:50:17 +13:00
return realm . create < SVG : : SVGTextElement > ( document , move ( qualified_name ) ) ;
2023-12-17 18:35:21 +00:00
if ( local_name = = SVG : : TagNames : : textPath )
2024-11-14 05:50:17 +13:00
return realm . create < SVG : : SVGTextPathElement > ( document , move ( qualified_name ) ) ;
2023-06-08 11:46:44 -04:00
if ( local_name = = SVG : : TagNames : : title )
2024-11-14 05:50:17 +13:00
return realm . create < SVG : : SVGTitleElement > ( document , move ( qualified_name ) ) ;
2023-07-22 19:34:51 +01:00
if ( local_name = = SVG : : TagNames : : tspan )
2024-11-14 05:50:17 +13:00
return realm . create < SVG : : SVGTSpanElement > ( document , move ( qualified_name ) ) ;
2023-05-30 21:23:52 +01:00
if ( local_name = = SVG : : TagNames : : use )
2024-11-14 05:50:17 +13:00
return realm . create < SVG : : SVGUseElement > ( document , move ( qualified_name ) ) ;
2023-09-23 08:56:49 +12:00
if ( local_name = = SVG : : TagNames : : script )
2024-11-14 05:50:17 +13:00
return realm . create < SVG : : SVGScriptElement > ( document , move ( qualified_name ) ) ;
2025-07-12 14:26:50 +01:00
if ( local_name = = SVG : : TagNames : : view )
return realm . create < SVG : : SVGViewElement > ( document , move ( qualified_name ) ) ;
2024-06-23 17:05:47 +02:00
if ( local_name = = SVG : : TagNames : : a )
2024-11-14 05:50:17 +13:00
return realm . create < SVG : : SVGAElement > ( document , move ( qualified_name ) ) ;
2024-08-20 15:12:55 +01:00
if ( local_name = = SVG : : TagNames : : image )
2024-11-14 05:50:17 +13:00
return realm . create < SVG : : SVGImageElement > ( document , move ( qualified_name ) ) ;
2020-08-09 17:10:41 +01:00
2024-10-31 10:35:07 +01:00
// https://svgwg.org/svg2-draft/types.html#ElementsInTheSVGDOM
// Elements in the SVG namespace whose local name does not match an element defined in any
// specification supported by the software must nonetheless implement the SVGElement interface.
2024-11-14 05:50:17 +13:00
return realm . create < SVG : : SVGElement > ( document , move ( qualified_name ) ) ;
2023-03-29 23:46:18 +01:00
}
2024-11-15 04:01:23 +13:00
static GC : : Ref < MathML : : MathMLElement > create_mathml_element ( JS : : Realm & realm , Document & document , QualifiedName qualified_name )
2023-07-05 20:25:52 -05:00
{
2024-10-31 10:35:07 +01:00
// https://w3c.github.io/mathml-core/#dom-and-javascript
// All the nodes representing MathML elements in the DOM must implement, and expose to scripts,
// the following MathMLElement interface.
2023-07-05 20:25:52 -05:00
2024-10-31 10:35:07 +01:00
// https://w3c.github.io/mathml-core/#mathml-elements-and-attributes
// The term MathML element refers to any element in the MathML namespace.
2023-07-05 20:25:52 -05:00
2024-11-14 05:50:17 +13:00
return realm . create < MathML : : MathMLElement > ( document , move ( qualified_name ) ) ;
2023-07-05 20:25:52 -05:00
}
2023-03-29 23:46:18 +01:00
// https://dom.spec.whatwg.org/#concept-create-element
2024-11-15 04:01:23 +13:00
WebIDL : : ExceptionOr < GC : : Ref < Element > > create_element ( Document & document , FlyString local_name , Optional < FlyString > namespace_ , Optional < FlyString > prefix , Optional < String > is_value , bool synchronous_custom_elements_flag )
2023-03-29 23:46:18 +01:00
{
auto & realm = document . realm ( ) ;
2025-02-02 14:47:12 +00:00
// 1. Let result be null.
2023-03-29 23:46:18 +01:00
// NOTE: We collapse this into just returning an element where necessary.
2025-02-02 14:47:12 +00:00
// 2. Let definition be the result of looking up a custom element definition given document, namespace, localName, and is.
2023-11-04 10:19:21 +01:00
auto definition = document . lookup_custom_element_definition ( namespace_ , local_name , is_value ) ;
2023-03-29 23:46:18 +01:00
2025-02-02 14:47:12 +00:00
// 3. If definition is non-null, and definition’ s name is not equal to its local name (i.e., definition represents a customized built-in element), then:
2023-03-29 23:46:18 +01:00
if ( definition & & definition - > name ( ) ! = definition - > local_name ( ) ) {
// 1. Let interface be the element interface for localName and the HTML namespace.
// 2. Set result to a new element that implements interface, with no attributes, namespace set to the HTML namespace,
// namespace prefix set to prefix, local name set to localName, custom element state set to "undefined", custom element definition set to null,
// is value set to is, and node document set to document.
2023-10-01 20:07:44 +13:00
auto element = create_html_element ( realm , document , QualifiedName { local_name , prefix , Namespace : : HTML } ) ;
2025-02-02 14:45:26 +00:00
element - > set_is_value ( is_value ) ;
2023-03-29 23:46:18 +01:00
// 3. If the synchronous custom elements flag is set, then run this step while catching any exceptions:
if ( synchronous_custom_elements_flag ) {
// 1. Upgrade element using definition.
auto upgrade_result = element - > upgrade_element ( * definition ) ;
// If this step threw an exception, then:
if ( upgrade_result . is_throw_completion ( ) ) {
2025-02-02 14:47:12 +00:00
// 1. Report exception for definition’ s constructor’ s corresponding JavaScript object’ s associated realm’ s global object.
auto & window_or_worker = as < HTML : : WindowOrWorkerGlobalScopeMixin > ( HTML : : relevant_global_object ( definition - > constructor ( ) . callback ) ) ;
window_or_worker . report_an_exception ( upgrade_result . error_value ( ) ) ;
2023-03-29 23:46:18 +01:00
// 2. Set result’ s custom element state to "failed".
element - > set_custom_element_state ( CustomElementState : : Failed ) ;
}
}
// 4. Otherwise, enqueue a custom element upgrade reaction given result and definition.
else {
element - > enqueue_a_custom_element_upgrade_reaction ( * definition ) ;
}
return element ;
2023-03-23 04:28:25 -04:00
}
2023-03-29 23:46:18 +01:00
2025-02-02 14:47:12 +00:00
// 4. Otherwise, if definition is non-null, then:
2023-03-29 23:46:18 +01:00
if ( definition ) {
2025-02-02 14:47:12 +00:00
// 1. If synchronousCustomElements is true, then run these steps while catching any exceptions:
2023-03-29 23:46:18 +01:00
if ( synchronous_custom_elements_flag ) {
2024-11-15 04:01:23 +13:00
auto synchronously_upgrade_custom_element = [ & ] ( ) - > JS : : ThrowCompletionOr < GC : : Ref < HTML : : HTMLElement > > {
2023-03-29 23:46:18 +01:00
// 1. Let C be definition’ s constructor.
auto & constructor = definition - > constructor ( ) ;
// 2. Set result to the result of constructing C, with no arguments.
2025-04-15 20:56:03 -04:00
auto result = TRY ( WebIDL : : construct ( constructor , { } ) ) ;
2023-03-29 23:46:18 +01:00
2025-01-09 21:36:40 +01:00
// NOTE: IDL does not currently convert the object for us, so we will have to do it here.
2025-04-04 18:11:45 +02:00
if ( ! result . is_object ( ) | | ! is < HTML : : HTMLElement > ( result . as_object ( ) ) )
2025-01-12 17:17:21 +00:00
return JS : : throw_completion ( JS : : TypeError : : create ( realm , " Custom element constructor must return an object that implements HTMLElement " _string ) ) ;
2023-03-29 23:46:18 +01:00
2025-04-04 18:11:45 +02:00
GC : : Ref < HTML : : HTMLElement > element = as < HTML : : HTMLElement > ( result . as_object ( ) ) ;
2023-03-29 23:46:18 +01:00
2025-01-09 21:36:40 +01:00
// FIXME: 3. Assert: result’ s custom element state and custom element definition are initialized.
// 4. Assert: result’ s namespace is the HTML namespace.
// Spec Note: IDL enforces that result is an HTMLElement object, which all use the HTML namespace.
VERIFY ( element - > namespace_uri ( ) = = Namespace : : HTML ) ;
2023-03-29 23:46:18 +01:00
// 5. If result’ s attribute list is not empty, then throw a "NotSupportedError" DOMException.
if ( element - > has_attributes ( ) )
2025-08-07 19:31:52 -04:00
return JS : : throw_completion ( WebIDL : : NotSupportedError : : create ( realm , " Synchronously created custom element cannot have attributes " _utf16 ) ) ;
2023-03-29 23:46:18 +01:00
// 6. If result has children, then throw a "NotSupportedError" DOMException.
if ( element - > has_children ( ) )
2025-08-07 19:31:52 -04:00
return JS : : throw_completion ( WebIDL : : NotSupportedError : : create ( realm , " Synchronously created custom element cannot have children " _utf16 ) ) ;
2023-03-29 23:46:18 +01:00
// 7. If result’ s parent is not null, then throw a "NotSupportedError" DOMException.
if ( element - > parent ( ) )
2025-08-07 19:31:52 -04:00
return JS : : throw_completion ( WebIDL : : NotSupportedError : : create ( realm , " Synchronously created custom element cannot have a parent " _utf16 ) ) ;
2023-03-29 23:46:18 +01:00
// 8. If result’ s node document is not document, then throw a "NotSupportedError" DOMException.
if ( & element - > document ( ) ! = & document )
2025-08-07 19:31:52 -04:00
return JS : : throw_completion ( WebIDL : : NotSupportedError : : create ( realm , " Synchronously created custom element must be in the same document that element creation was invoked in " _utf16 ) ) ;
2023-03-29 23:46:18 +01:00
// 9. If result’ s local name is not equal to localName, then throw a "NotSupportedError" DOMException.
if ( element - > local_name ( ) ! = local_name )
2025-08-07 19:31:52 -04:00
return JS : : throw_completion ( WebIDL : : NotSupportedError : : create ( realm , " Synchronously created custom element must have the same local name that element creation was invoked with " _utf16 ) ) ;
2023-03-29 23:46:18 +01:00
// 10. Set result’ s namespace prefix to prefix.
2023-11-04 09:22:31 +01:00
element - > set_prefix ( prefix ) ;
2023-03-29 23:46:18 +01:00
// 11. Set result’ s is value to null.
element - > set_is_value ( Optional < String > { } ) ;
return element ;
} ;
auto result = synchronously_upgrade_custom_element ( ) ;
// If any of these steps threw an exception, then:
if ( result . is_throw_completion ( ) ) {
2025-02-02 14:47:12 +00:00
// 1. Report exception for definition’ s constructor’ s corresponding JavaScript object’ s associated realm’ s global object.
auto & window_or_worker = as < HTML : : WindowOrWorkerGlobalScopeMixin > ( HTML : : relevant_global_object ( definition - > constructor ( ) . callback ) ) ;
window_or_worker . report_an_exception ( result . error_value ( ) ) ;
2023-03-29 23:46:18 +01:00
// 2. Set result to a new element that implements the HTMLUnknownElement interface, with no attributes, namespace set to the HTML namespace, namespace prefix set to prefix,
// local name set to localName, custom element state set to "failed", custom element definition set to null, is value set to null, and node document set to document.
2024-11-15 04:01:23 +13:00
GC : : Ref < Element > element = realm . create < HTML : : HTMLUnknownElement > ( document , QualifiedName { local_name , prefix , Namespace : : HTML } ) ;
2023-03-29 23:46:18 +01:00
element - > set_custom_element_state ( CustomElementState : : Failed ) ;
return element ;
}
return result . release_value ( ) ;
}
// 2. Otherwise:
// 1. Set result to a new element that implements the HTMLElement interface, with no attributes, namespace set to the HTML namespace, namespace prefix set to prefix,
// local name set to localName, custom element state set to "undefined", custom element definition set to null, is value set to null, and node document set to document.
2024-11-14 05:50:17 +13:00
auto element = realm . create < HTML : : HTMLElement > ( document , QualifiedName { local_name , prefix , Namespace : : HTML } ) ;
2023-03-29 23:46:18 +01:00
element - > set_custom_element_state ( CustomElementState : : Undefined ) ;
// 2. Enqueue a custom element upgrade reaction given result and definition.
element - > enqueue_a_custom_element_upgrade_reaction ( * definition ) ;
return element ;
}
2025-02-02 14:47:12 +00:00
// 5. Otherwise:
2023-03-29 23:46:18 +01:00
// 1. Let interface be the element interface for localName and namespace.
// 2. Set result to a new element that implements interface, with no attributes, namespace set to namespace, namespace prefix set to prefix,
// local name set to localName, custom element state set to "uncustomized", custom element definition set to null, is value set to is,
// and node document set to document.
2023-10-01 20:07:44 +13:00
auto qualified_name = QualifiedName { local_name , prefix , namespace_ } ;
2023-03-29 23:46:18 +01:00
2023-11-04 18:42:04 +01:00
if ( namespace_ = = Namespace : : HTML ) {
2023-08-13 13:05:26 +02:00
auto element = create_html_element ( realm , document , move ( qualified_name ) ) ;
2025-02-13 12:55:12 +00:00
element - > set_is_value ( is_value ) ;
2023-03-29 23:46:18 +01:00
element - > set_custom_element_state ( CustomElementState : : Uncustomized ) ;
// 3. If namespace is the HTML namespace, and either localName is a valid custom element name or is is non-null,
// then set result’ s custom element state to "undefined".
if ( HTML : : is_valid_custom_element_name ( local_name ) | | is_value . has_value ( ) )
element - > set_custom_element_state ( CustomElementState : : Undefined ) ;
return element ;
}
2023-11-04 18:42:04 +01:00
if ( namespace_ = = Namespace : : SVG ) {
2023-08-13 13:05:26 +02:00
auto element = create_svg_element ( realm , document , qualified_name ) ;
2025-02-13 12:55:12 +00:00
element - > set_is_value ( is_value ) ;
2024-10-31 10:35:07 +01:00
element - > set_custom_element_state ( CustomElementState : : Uncustomized ) ;
return element ;
2023-03-29 23:46:18 +01:00
}
2023-11-04 18:42:04 +01:00
if ( namespace_ = = Namespace : : MathML ) {
2023-08-13 13:05:26 +02:00
auto element = create_mathml_element ( realm , document , qualified_name ) ;
2025-02-13 12:55:12 +00:00
element - > set_is_value ( is_value ) ;
2024-10-31 10:35:07 +01:00
element - > set_custom_element_state ( CustomElementState : : Uncustomized ) ;
return element ;
2023-07-05 20:25:52 -05:00
}
2025-02-02 14:47:12 +00:00
// 6. Return result.
// NOTE: See step 1.
2023-03-29 23:46:18 +01:00
// https://dom.spec.whatwg.org/#concept-element-interface
// The element interface for any name and namespace is Element, unless stated otherwise.
2024-11-14 05:50:17 +13:00
auto element = realm . create < DOM : : Element > ( document , move ( qualified_name ) ) ;
2023-03-29 23:46:18 +01:00
element - > set_is_value ( move ( is_value ) ) ;
element - > set_custom_element_state ( CustomElementState : : Uncustomized ) ;
return element ;
2019-10-12 13:02:38 +02:00
}
2020-03-07 10:27:02 +01:00
}