Commit 696e8faa authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Add IHTMLElement6::hasAttribute implementation.

parent 83fc6f0e
...@@ -202,6 +202,22 @@ HRESULT elem_string_attr_setter(HTMLElement *elem, const WCHAR *name, const WCHA ...@@ -202,6 +202,22 @@ HRESULT elem_string_attr_setter(HTMLElement *elem, const WCHAR *name, const WCHA
return S_OK; return S_OK;
} }
static VARIANT_BOOL element_has_attribute(HTMLElement *element, const WCHAR *name)
{
nsAString name_str;
cpp_bool r;
nsresult nsres;
if(!element->dom_element) {
WARN("no DOM element\n");
return VARIANT_FALSE;
}
nsAString_InitDepend(&name_str, name);
nsres = nsIDOMElement_HasAttribute(element->dom_element, &name_str, &r);
return variant_bool(NS_SUCCEEDED(nsres) && r);
}
HRESULT get_readystate_string(READYSTATE readystate, BSTR *p) HRESULT get_readystate_string(READYSTATE readystate, BSTR *p)
{ {
static const LPCWSTR readystate_strs[] = { static const LPCWSTR readystate_strs[] = {
...@@ -4453,11 +4469,14 @@ static HRESULT WINAPI HTMLElement6_removeAttributeNode(IHTMLElement6 *iface, IHT ...@@ -4453,11 +4469,14 @@ static HRESULT WINAPI HTMLElement6_removeAttributeNode(IHTMLElement6 *iface, IHT
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT WINAPI HTMLElement6_hasAttribute(IHTMLElement6 *iface, BSTR name, VARIANT_BOOL *pfHasAttribute) static HRESULT WINAPI HTMLElement6_hasAttribute(IHTMLElement6 *iface, BSTR name, VARIANT_BOOL *p)
{ {
HTMLElement *This = impl_from_IHTMLElement6(iface); HTMLElement *This = impl_from_IHTMLElement6(iface);
FIXME("(%p)->(%s %p)\n", This, debugstr_w(name), pfHasAttribute);
return E_NOTIMPL; TRACE("(%p)->(%s %p)\n", This, debugstr_w(name), p);
*p = element_has_attribute(This, name);
return S_OK;
} }
static HRESULT WINAPI HTMLElement6_getElementsByTagNameNS(IHTMLElement6 *iface, VARIANT *varNS, BSTR bstrLocalName, IHTMLElementCollection **pelColl) static HRESULT WINAPI HTMLElement6_getElementsByTagNameNS(IHTMLElement6 *iface, VARIANT *varNS, BSTR bstrLocalName, IHTMLElementCollection **pelColl)
......
...@@ -468,3 +468,23 @@ sync_test("title", function() { ...@@ -468,3 +468,23 @@ sync_test("title", function() {
ok(elem.title === "test", "div.title = " + elem.title); ok(elem.title === "test", "div.title = " + elem.title);
ok(elem.getAttribute("title") === "test", "title attribute = " + elem.getAttribute("title")); ok(elem.getAttribute("title") === "test", "title attribute = " + elem.getAttribute("title"));
}); });
sync_test("hasAttribute", function() {
document.body.innerHTML = '<div attr="test"></div>';
var elem = document.body.firstChild, r;
r = elem.hasAttribute("attr");
ok(r === true, "hasAttribute(attr) returned " + r);
r = elem.hasAttribute("attr2");
ok(r === false, "hasAttribute(attr2) returned " + r);
elem.setAttribute("attr2", "abc");
r = elem.hasAttribute("attr2");
todo_wine.
ok(r === true, "hasAttribute(attr2) returned " + r);
elem.removeAttribute("attr");
r = elem.hasAttribute("attr");
todo_wine.
ok(r === false, "hasAttribute(attr) returned " + r);
});
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