Module: wine Branch: master Commit: 808fcf23c78c30997fc4e44d4b201cf5a3c2ba71 URL: https://gitlab.winehq.org/wine/wine/-/commit/808fcf23c78c30997fc4e44d4b201cf...
Author: Gabriel Ivăncescu gabrielopcode@gmail.com Date: Fri May 26 17:04:39 2023 +0300
mshtml: Implement classList's length prop.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com
---
dlls/mshtml/htmlelem.c | 31 +++++++++++++++++++++++++++++-- dlls/mshtml/tests/dom.js | 5 +++++ 2 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index 807457b087b..fd3cf149619 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -7599,10 +7599,37 @@ static HRESULT WINAPI token_list_contains(IWineDOMTokenList *iface, BSTR token, static HRESULT WINAPI token_list_get_length(IWineDOMTokenList *iface, LONG *p) { struct token_list *token_list = impl_from_IWineDOMTokenList(iface); + unsigned length = 0; + const WCHAR *ptr; + HRESULT hres; + BSTR list;
- FIXME("(%p)->(%p)\n", token_list, p); + TRACE("(%p)->(%p)\n", token_list, p);
- return E_NOTIMPL; + hres = IHTMLElement_get_className(token_list->element, &list); + if(FAILED(hres)) + return hres; + + if(!list) { + *p = 0; + return S_OK; + } + + ptr = list; + do { + while(iswspace(*ptr)) + ptr++; + if(!*ptr) + break; + length++; + ptr++; + while(*ptr && !iswspace(*ptr)) + ptr++; + } while(*ptr++); + + SysFreeString(list); + *p = length; + return S_OK; }
static HRESULT WINAPI token_list_item(IWineDOMTokenList *iface, LONG index, VARIANT *p) diff --git a/dlls/mshtml/tests/dom.js b/dlls/mshtml/tests/dom.js index f373cfb11ea..67eb702452d 100644 --- a/dlls/mshtml/tests/dom.js +++ b/dlls/mshtml/tests/dom.js @@ -635,15 +635,19 @@ sync_test("classList", function() {
classList.add("a"); ok(elem.className === "a", "Expected className 'a', got " + elem.className); + ok(classList.length === 1, "Expected length 1 for className 'a', got " + classList.length);
classList.add("b"); ok(elem.className === "a b", "Expected className 'a b', got " + elem.className); + ok(classList.length === 2, "Expected length 2 for className 'a b', got " + classList.length);
classList.add("c"); ok(elem.className === "a b c", "Expected className 'a b c', got " + elem.className); + ok(classList.length === 3, "Expected length 3 for className 'a b c', got " + classList.length);
classList.add(4); ok(elem.className === "a b c 4", "Expected className 'a b c 4', got " + elem.className); + ok(classList.length === 4, "Expected length 4 for className 'a b c 4', got " + classList.length);
classList.add("c"); ok(elem.className === "a b c 4", "(2) Expected className 'a b c 4', got " + elem.className); @@ -820,6 +824,7 @@ sync_test("classList", function() { ok(elem.className === "abc", "toggle('123', null): got className " + elem.className);
elem.className = " testclass foobar "; + ok(classList.length === 2, "Expected length 2 for className ' testclass foobar ', got " + classList.length); ok(("" + classList) === " testclass foobar ", "Expected classList value ' testclass foobar ', got " + classList); ok(classList.toString() === " testclass foobar ", "Expected classList toString ' testclass foobar ', got " + classList.toString()); });