Commit 39434794 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Add IElementSelector::querySelector implementation.

parent 4257a14f
......@@ -5182,8 +5182,39 @@ static HRESULT WINAPI ElementSelector_Invoke(IElementSelector *iface, DISPID dis
static HRESULT WINAPI ElementSelector_querySelector(IElementSelector *iface, BSTR v, IHTMLElement **pel)
{
HTMLElement *This = impl_from_IElementSelector(iface);
FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
return E_NOTIMPL;
nsIDOMElement *nselem;
HTMLElement *elem;
nsAString nsstr;
nsresult nsres;
HRESULT hres;
TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
if(!This->dom_element) {
FIXME("comment element\n");
return E_NOTIMPL;
}
nsAString_InitDepend(&nsstr, v);
nsres = nsIDOMElement_QuerySelector(This->dom_element, &nsstr, &nselem);
nsAString_Finish(&nsstr);
if(NS_FAILED(nsres)) {
ERR("QuerySelector failed: %08x\n", nsres);
return E_FAIL;
}
if(!nselem) {
*pel = NULL;
return S_OK;
}
hres = get_element(nselem, &elem);
nsIDOMElement_Release(nselem);
if(FAILED(hres))
return hres;
*pel = &elem->IHTMLElement_iface;
return S_OK;
}
static HRESULT WINAPI ElementSelector_querySelectorAll(IElementSelector *iface, BSTR v, IHTMLDOMChildrenCollection **pel)
......
......@@ -200,12 +200,18 @@ function test_query_selector() {
var e = document.querySelector("nomatch");
ok(e === null, "e = " + e);
e = document.body.querySelector("nomatch");
ok(e === null, "e = " + e);
e = document.querySelector(".class1");
ok(e.tagName === "DIV", "e.tagName = " + e.tagName);
e = document.body.querySelector(".class1");
ok(e.tagName === "DIV", "e.tagName = " + e.tagName);
e = document.querySelector("a");
ok(e.tagName === "A", "e.tagName = " + e.tagName);
e = document.body.querySelector("a");
ok(e.tagName === "A", "e.tagName = " + e.tagName);
next_test();
}
......
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