Commit 808fcf23 authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard

mshtml: Implement classList's length prop.

parent fcaa9bbe
......@@ -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)
......
......@@ -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());
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment