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

mshtml: Implement classList's item() method.

parent 808fcf23
......@@ -7635,10 +7635,53 @@ static HRESULT WINAPI token_list_get_length(IWineDOMTokenList *iface, LONG *p)
static HRESULT WINAPI token_list_item(IWineDOMTokenList *iface, LONG index, VARIANT *p)
{
struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
BSTR list, token = NULL;
unsigned i = 0;
HRESULT hres;
WCHAR *ptr;
FIXME("(%p)->(%ld %p)\n", token_list, index, p);
TRACE("(%p)->(%ld %p)\n", token_list, index, p);
return E_NOTIMPL;
hres = IHTMLElement_get_className(token_list->element, &list);
if(FAILED(hres))
return hres;
if(!list) {
V_VT(p) = VT_NULL;
return S_OK;
}
ptr = list;
do {
while(iswspace(*ptr))
ptr++;
if(!*ptr)
break;
if(i == index) {
token = ptr++;
while(*ptr && !iswspace(*ptr))
ptr++;
token = SysAllocStringLen(token, ptr - token);
if(!token) {
SysFreeString(list);
return E_OUTOFMEMORY;
}
break;
}
i++;
ptr++;
while(*ptr && !iswspace(*ptr))
ptr++;
} while(*ptr++);
SysFreeString(list);
if(!token)
V_VT(p) = VT_NULL;
else {
V_VT(p) = VT_BSTR;
V_BSTR(p) = token;
}
return S_OK;
}
static HRESULT WINAPI token_list_toString(IWineDOMTokenList *iface, BSTR *String)
......
......@@ -726,6 +726,19 @@ sync_test("classList", function() {
ok(classList.contains("b") === true, "contains: expected 'b' to return true");
ok(classList.contains("d") === false, "contains: expected 'd' to return false");
r = classList.item(-1);
ok(r === null, "item(-1) = " + r);
r = classList.item(0);
ok(r === "a", "item(0) = " + r);
r = classList.item(1);
ok(r === "b", "item(1) = " + r);
r = classList.item(2);
ok(r === "c", "item(2) = " + r);
r = classList.item(3);
ok(r === "4", "item(3) = " + r);
r = classList.item(4);
ok(r === null, "item(4) = " + r);
classList.remove("e");
ok(elem.className === "a b c 4", "remove: expected className 'a b c 4', got " + elem.className);
......
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