mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 04:25:13 +00:00
LibWeb: Verify element namespace in DOM::create_element()
This commit is contained in:
parent
00ed797627
commit
19f97472eb
Notes:
github-actions[bot]
2025-01-11 22:30:15 +00:00
Author: https://github.com/Psychpsyo Commit: https://github.com/LadybirdBrowser/ladybird/commit/19f97472eb9 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3200 Reviewed-by: https://github.com/gmta ✅
1 changed files with 7 additions and 5 deletions
|
@ -576,16 +576,18 @@ WebIDL::ExceptionOr<GC::Ref<Element>> create_element(Document& document, FlyStri
|
|||
// 2. Set result to the result of constructing C, with no arguments.
|
||||
auto result = TRY(WebIDL::construct(constructor));
|
||||
|
||||
// FIXME: 3. Assert: result’s custom element state and custom element definition are initialized.
|
||||
// FIXME: 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.
|
||||
// IDL does not currently convert the object for us, so we will have to do it here.
|
||||
|
||||
// NOTE: IDL does not currently convert the object for us, so we will have to do it here.
|
||||
if (!result.has_value() || !result->is_object() || !is<HTML::HTMLElement>(result->as_object()))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotAnObjectOfType, "HTMLElement"sv);
|
||||
|
||||
GC::Ref<HTML::HTMLElement> element = verify_cast<HTML::HTMLElement>(result->as_object());
|
||||
|
||||
// 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);
|
||||
|
||||
// 5. If result’s attribute list is not empty, then throw a "NotSupportedError" DOMException.
|
||||
if (element->has_attributes())
|
||||
return JS::throw_completion(WebIDL::NotSupportedError::create(realm, "Synchronously created custom element cannot have attributes"_string));
|
||||
|
|
Loading…
Add table
Reference in a new issue