[PATCH 2/7] mshtml: Implement proper value for WineDOMTokenList.

Gabriel Ivăncescu gabrielopcode at gmail.com
Fri Oct 1 08:12:43 CDT 2021


It returns the classes as specified in className.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
---
 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 d9554f4..4e5aba7 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 0085b40..efbab66 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);
 });
-- 
2.31.1




More information about the wine-devel mailing list