From 31883ce4ac5231ba528f09b6b4f04067cde40bf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Iv=C4=83ncescu?= Date: Fri, 1 Oct 2021 16:12:43 +0300 Subject: [PATCH] mshtml: Implement proper value for WineDOMTokenList. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It returns the classes as specified in className. Signed-off-by: Gabriel Ivăncescu Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/mshtml/htmlelem.c | 32 +++++++++++++++++++++++++++++++- dlls/mshtml/tests/dom.js | 4 ++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index d9554f4668d..4e5aba7c344 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -6624,12 +6624,42 @@ static const IWineDOMTokenListVtbl WineDOMTokenListVtbl = { token_list_remove, }; +static inline struct token_list *token_list_from_DispatchEx(DispatchEx *iface) +{ + return CONTAINING_RECORD(iface, struct token_list, dispex); +} + +static HRESULT token_list_value(DispatchEx *dispex, LCID lcid, WORD flags, DISPPARAMS *params, + VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller) +{ + struct token_list *token_list = token_list_from_DispatchEx(dispex); + HRESULT hres; + + switch(flags) { + case DISPATCH_PROPERTYGET: + hres = IHTMLElement_get_className(token_list->element, &V_BSTR(res)); + if(FAILED(hres)) + return hres; + V_VT(res) = VT_BSTR; + break; + default: + FIXME("Unimplemented flags %x\n", flags); + return E_NOTIMPL; + } + + return S_OK; +} + +static const dispex_static_data_vtbl_t token_list_dispex_vtbl = { + token_list_value +}; + static const tid_t token_list_iface_tids[] = { IWineDOMTokenList_tid, 0 }; static dispex_static_data_t token_list_dispex = { - NULL, + &token_list_dispex_vtbl, IWineDOMTokenList_tid, token_list_iface_tids }; diff --git a/dlls/mshtml/tests/dom.js b/dlls/mshtml/tests/dom.js index 0085b40efed..efbab663902 100644 --- a/dlls/mshtml/tests/dom.js +++ b/dlls/mshtml/tests/dom.js @@ -527,6 +527,7 @@ sync_test("classList", function() { classList.add("c"); ok(elem.className === "a b c 4", "(2) Expected className 'a b c 4', got " + elem.className); + ok(("" + classList) === "a b c 4", "Expected classList value 'a b c 4', got " + classList); var exception = false @@ -605,4 +606,7 @@ sync_test("classList", function() { classList.remove("b"); ok(elem.className === "", "remove: expected className '', got " + elem.className); + + elem.className = " testclass foobar "; + ok(("" + classList) === " testclass foobar ", "Expected classList value ' testclass foobar ', got " + classList); });