diff options
Diffstat (limited to 'Source/WebCore/bindings/js/JSHTMLSelectElementCustom.cpp')
-rw-r--r-- | Source/WebCore/bindings/js/JSHTMLSelectElementCustom.cpp | 43 |
1 files changed, 11 insertions, 32 deletions
diff --git a/Source/WebCore/bindings/js/JSHTMLSelectElementCustom.cpp b/Source/WebCore/bindings/js/JSHTMLSelectElementCustom.cpp index 43f694b50..c74aed3df 100644 --- a/Source/WebCore/bindings/js/JSHTMLSelectElementCustom.cpp +++ b/Source/WebCore/bindings/js/JSHTMLSelectElementCustom.cpp @@ -21,55 +21,34 @@ #include "config.h" #include "JSHTMLSelectElementCustom.h" +#include "CustomElementReactionQueue.h" #include "ExceptionCode.h" #include "HTMLNames.h" #include "HTMLOptionElement.h" #include "HTMLSelectElement.h" #include "JSHTMLOptionElement.h" +#include "JSHTMLSelectElement.h" namespace WebCore { using namespace JSC; using namespace HTMLNames; -JSValue JSHTMLSelectElement::remove(ExecState* exec) +void selectElementIndexSetter(JSC::ExecState& state, HTMLSelectElement& element, unsigned index, JSC::JSValue value) { - HTMLSelectElement& select = impl(); + VM& vm = state.vm(); + auto throwScope = DECLARE_THROW_SCOPE(vm); - if (!exec->argumentCount()) { - // When called with no argument, we should call Element::remove() to detach. - ExceptionCode ec = 0; - select.remove(ec); - setDOMException(exec, ec); - } else { - // The HTMLSelectElement::remove() function can take either an option object or the index of an option. - if (HTMLOptionElement* option = toHTMLOptionElement(exec->argument(0))) - select.remove(option); - else - select.removeByIndex(exec->argument(0).toInt32(exec)); - } + auto* option = convert<IDLNullable<IDLInterface<HTMLOptionElement>>>(state, value); + RETURN_IF_EXCEPTION(throwScope, void()); - return jsUndefined(); + propagateException(state, throwScope, element.setItem(index, option)); } -void selectIndexSetter(HTMLSelectElement* select, JSC::ExecState* exec, unsigned index, JSC::JSValue value) +void JSHTMLSelectElement::indexSetter(JSC::ExecState* state, unsigned index, JSC::JSValue value) { - if (value.isUndefinedOrNull()) - select->removeByIndex(index); - else { - ExceptionCode ec = 0; - HTMLOptionElement* option = toHTMLOptionElement(value); - if (!option) - ec = TYPE_MISMATCH_ERR; - else - select->setOption(index, option, ec); - setDOMException(exec, ec); - } -} - -void JSHTMLSelectElement::indexSetter(JSC::ExecState* exec, unsigned index, JSC::JSValue value) -{ - selectIndexSetter(&impl(), exec, index, value); + CustomElementReactionStack customElementReactionStack; + selectElementIndexSetter(*state, wrapped(), index, value); } } |