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

mshtml: Implement classList's contains() method.

parent ced75455
...@@ -7573,10 +7573,26 @@ static HRESULT WINAPI token_list_toggle(IWineDOMTokenList *iface, BSTR token, VA ...@@ -7573,10 +7573,26 @@ static HRESULT WINAPI token_list_toggle(IWineDOMTokenList *iface, BSTR token, VA
static HRESULT WINAPI token_list_contains(IWineDOMTokenList *iface, BSTR token, VARIANT_BOOL *p) static HRESULT WINAPI token_list_contains(IWineDOMTokenList *iface, BSTR token, VARIANT_BOOL *p)
{ {
struct token_list *token_list = impl_from_IWineDOMTokenList(iface); struct token_list *token_list = impl_from_IWineDOMTokenList(iface);
unsigned len;
HRESULT hres;
BSTR list;
FIXME("(%p)->(%s %p)\n", token_list, debugstr_w(token), p); TRACE("(%p)->(%s %p)\n", token_list, debugstr_w(token), p);
return E_NOTIMPL; if(!token || !*token)
return E_INVALIDARG;
for(len = 0; token[len]; len++)
if(iswspace(token[len]))
return E_INVALIDARG;
hres = IHTMLElement_get_className(token_list->element, &list);
if(FAILED(hres))
return hres;
*p = find_token(list, token, len) ? VARIANT_TRUE : VARIANT_FALSE;
SysFreeString(list);
return S_OK;
} }
static HRESULT WINAPI token_list_get_length(IWineDOMTokenList *iface, LONG *p) static HRESULT WINAPI token_list_get_length(IWineDOMTokenList *iface, LONG *p)
......
...@@ -685,6 +685,43 @@ sync_test("classList", function() { ...@@ -685,6 +685,43 @@ sync_test("classList", function() {
} }
ok(exception, "Expected exception for classList.add(\"e f\")"); ok(exception, "Expected exception for classList.add(\"e f\")");
exception = false;
try
{
classList.contains();
}
catch(e)
{
exception = true;
}
ok(exception, "Expected exception for classList.contains()");
exception = false;
try
{
classList.contains("");
}
catch(e)
{
exception = true;
}
ok(exception, "Expected exception for classList.contains(\"\")");
exception = false;
try
{
classList.contains("a b");
}
catch(e)
{
exception = true;
}
ok(exception, "Expected exception for classList.contains(\"a b\")");
ok(classList.contains("4") === true, "contains: expected '4' to return true");
ok(classList.contains("b") === true, "contains: expected 'b' to return true");
ok(classList.contains("d") === false, "contains: expected 'd' to return false");
classList.remove("e"); classList.remove("e");
ok(elem.className === "a b c 4", "remove: expected className 'a b c 4', got " + elem.className); 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