Commit 68b8b7b4 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Added IHTMLDocument7::getElementsByClassName implementation.

parent b244182b
......@@ -3347,11 +3347,32 @@ static HRESULT WINAPI HTMLDocument7_createAttribute(IHTMLDocument7 *iface, BSTR
return IHTMLDocument5_createAttribute(&This->IHTMLDocument5_iface, bstrAttrName, ppAttribute);
}
static HRESULT WINAPI HTMLDocument7_getElementByClassName(IHTMLDocument7 *iface, BSTR v, IHTMLElementCollection **pel)
static HRESULT WINAPI HTMLDocument7_getElementsByClassName(IHTMLDocument7 *iface, BSTR v, IHTMLElementCollection **pel)
{
HTMLDocument *This = impl_from_IHTMLDocument7(iface);
FIXME("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
return E_NOTIMPL;
nsIDOMNodeList *nslist;
nsAString nsstr;
nsresult nsres;
TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
if(!This->doc_node->nsdoc) {
FIXME("NULL nsdoc not supported\n");
return E_NOTIMPL;
}
nsAString_InitDepend(&nsstr, v);
nsres = nsIDOMHTMLDocument_GetElementsByClassName(This->doc_node->nsdoc, &nsstr, &nslist);
nsAString_Finish(&nsstr);
if(FAILED(nsres)) {
ERR("GetElementByClassName failed: %08x\n", nsres);
return E_FAIL;
}
*pel = create_collection_from_nodelist(This->doc_node, nslist);
nsIDOMNodeList_Release(nslist);
return S_OK;
}
static HRESULT WINAPI HTMLDocument7_createProcessingInstruction(IHTMLDocument7 *iface, BSTR target,
......@@ -4091,7 +4112,7 @@ static const IHTMLDocument7Vtbl HTMLDocument7Vtbl = {
HTMLDocument7_get_characterSet,
HTMLDocument7_createElement,
HTMLDocument7_createAttribute,
HTMLDocument7_getElementByClassName,
HTMLDocument7_getElementsByClassName,
HTMLDocument7_createProcessingInstruction,
HTMLDocument7_adoptNode,
HTMLDocument7_put_onmssitemodejumplistitemremoved,
......
......@@ -104,9 +104,35 @@ function test_head() {
next_test();
}
function test_getElementsByClassName() {
var elems;
document.body.innerHTML = '<div class="class1">'
+ '<div class="class1"></div>'
+ '<a id="class1" class="class2"></a>'
+ '</div>'
+ '<script class="class1"></script>';
elems = document.getElementsByClassName("class1");
ok(elems.length === 3, "elems.length = " + elems.length);
ok(elems[0].tagName === "DIV", "elems[0].tagName = " + elems[0].tagName);
ok(elems[1].tagName === "DIV", "elems[1].tagName = " + elems[1].tagName);
ok(elems[2].tagName === "SCRIPT", "elems[2].tagName = " + elems[2].tagName);
elems = document.getElementsByClassName("class2");
ok(elems.length === 1, "elems.length = " + elems.length);
ok(elems[0].tagName === "A", "elems[0].tagName = " + elems[0].tagName);
elems = document.getElementsByClassName("classnotfound");
ok(elems.length == 0, "elems.length = " + elems.length);
next_test();
}
var tests = [
test_input_selection,
test_textContent,
test_ElementTraversal,
test_getElementsByClassName,
test_head
];
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