Commit 3d505b12 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Added IDocumentSelector::querySelector implementation.

parent eafbe884
......@@ -4262,8 +4262,32 @@ static HRESULT WINAPI DocumentSelector_Invoke(IDocumentSelector *iface, DISPID d
static HRESULT WINAPI DocumentSelector_querySelector(IDocumentSelector *iface, BSTR v, IHTMLElement **pel)
{
HTMLDocument *This = impl_from_IDocumentSelector(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);
nsAString_InitDepend(&nsstr, v);
nsres = nsIDOMHTMLDocument_QuerySelector(This->doc_node->nsdoc, &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_elem(This->doc_node, nselem, &elem);
nsIDOMElement_Release(nselem);
if(SUCCEEDED(hres))
*pel = &elem->IHTMLElement_iface;
return S_OK;
}
static HRESULT WINAPI DocumentSelector_querySelectorAll(IDocumentSelector *iface, BSTR v, IHTMLDOMChildrenCollection **pel)
......
......@@ -129,10 +129,30 @@ function test_getElementsByClassName() {
next_test();
}
function test_query_selector() {
document.body.innerHTML = '<div class="class1">'
+ '<div class="class1"></div>'
+ '<a id="class1" class="class2"></a>'
+ '</div>'
+ '<script class="class1"></script>';
var e = document.querySelector("nomatch");
ok(e === null, "e = " + e);
e = document.querySelector(".class1");
ok(e.tagName === "DIV", "e.tagName = " + e.tagName);
e = document.querySelector("a");
ok(e.tagName === "A", "e.tagName = " + e.tagName);
next_test();
}
var tests = [
test_input_selection,
test_textContent,
test_ElementTraversal,
test_getElementsByClassName,
test_head
test_head,
test_query_selector
];
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