dymokomi/luce-browser-engine
Source of release 0.6.1
0.6.1 / src / web / bindings / option_constructor.lucb
#==============================================================================================
#
# option_constructor - Bindings::OptionConstructor: the legacy factory function Option()
#
# DESCRIPTION:
# Port of Libraries/LibWeb/Bindings/OptionConstructor.cpp (lines 1-94) and OptionConstructor.h (lines
# 1-30). `new Option(...)` creates an <option> element; OptionConstructor is a JS::NativeFunction,
# a JS object, so it comes with luce-js in phase 3 (DESIGN.md ยง3.6): the functions are
# here with their steps, and trap until then.
#
# Copyright (c) 2022, the SerenityOS developers.
# SPDX-License-Identifier: BSD-2-Clause
#
#==============================================================================================
## Ported from Libraries/LibWeb/Bindings/OptionConstructor.cpp:23 Web::Bindings::OptionConstructor::OptionConstructor:
## NativeFunction(realm.intrinsics().function_prototype()).
pub func bind_option_constructor_construct_realm(this: BindOptionConstructor*, realm: Realm*):
trap("unported (P3): Web::Bindings::OptionConstructor::OptionConstructor (a JS::NativeFunction)")
## Ported from Libraries/LibWeb/Bindings/OptionConstructor.cpp:28 Web::Bindings::OptionConstructor::initialize (override):
## the function's length (0), name ("Option") and prototype (HTMLOptionElement's) properties.
pub func bind_option_constructor_initialize_impl(base: JsCell*, realm: Realm*):
trap("unported (P3): Web::Bindings::OptionConstructor::initialize (JS properties)")
## Ported from Libraries/LibWeb/Bindings/OptionConstructor.cpp:38 Web::Bindings::OptionConstructor::call (virtual):
## a TypeError (ConstructorWithoutNew, "Option").
pub func bind_option_constructor_call_impl(this: BindOptionConstructor*) -> JsValue!:
trap("unported (P3): Web::Bindings::OptionConstructor::call (a JS TypeError)")
## Ported from Libraries/LibWeb/Bindings/OptionConstructor.cpp:45 Web::Bindings::OptionConstructor::construct (virtual).
## https://html.spec.whatwg.org/multipage/form-elements.html#dom-option
## https://webidl.spec.whatwg.org/#legacy-factory-functions
pub func bind_option_constructor_construct_js_function_object_impl(this: BindOptionConstructor*, new_target: JsFunctionObject*) -> JsObject*!:
# 1. Let document be the current global object's associated Document.
# 2. Let option be the result of creating an element given document, "option", and the HTML namespace.
# 3. If text is not the empty string, then append to option a new Text node whose data is text.
# 4. If value is given, then set an attribute value for option using "value" and value.
# 5. If defaultSelected is true, then set an attribute value for option using "selected" and the empty string.
# 6. If selected is true, then set option's selectedness to true; otherwise set its selectedness to false (even if defaultSelected is true).
# 7. Return option.
# (The arguments are JS values and the result is the element's wrapper: phase 3.)
trap("unported (P3): Web::Bindings::OptionConstructor::construct (JS arguments and wrapper)")
## Ported from Libraries/LibWeb/Bindings/OptionConstructor.h:27 Web::Bindings::OptionConstructor::has_constructor (virtual).
pub func bind_option_constructor_has_constructor_impl(this: BindOptionConstructor*) -> bool:
return true