mshtml: Add IHTMLDocument7::createElementNS implementation.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2019-03-28 15:55:46 +01:00 committed by Alexandre Julliard
parent 3dc6d9d914
commit 7858cc01b7
2 changed files with 53 additions and 2 deletions

View File

@ -3288,8 +3288,39 @@ static HRESULT WINAPI HTMLDocument7_getElementsByTagNameNS(IHTMLDocument7 *iface
static HRESULT WINAPI HTMLDocument7_createElementNS(IHTMLDocument7 *iface, VARIANT *pvarNS, BSTR bstrTag, IHTMLElement **newElem)
{
HTMLDocument *This = impl_from_IHTMLDocument7(iface);
FIXME("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrTag), newElem);
return E_NOTIMPL;
nsIDOMElement *dom_element;
HTMLElement *element;
nsAString ns, tag;
nsresult nsres;
HRESULT hres;
TRACE("(%p)->(%s %s %p)\n", This, debugstr_variant(pvarNS), debugstr_w(bstrTag), newElem);
if(!This->doc_node->nsdoc) {
FIXME("NULL nsdoc\n");
return E_FAIL;
}
if(pvarNS && V_VT(pvarNS) != VT_NULL && V_VT(pvarNS) != VT_BSTR)
FIXME("Unsupported namespace %s\n", debugstr_variant(pvarNS));
nsAString_InitDepend(&ns, pvarNS && V_VT(pvarNS) == VT_BSTR ? V_BSTR(pvarNS) : NULL);
nsAString_InitDepend(&tag, bstrTag);
nsres = nsIDOMHTMLDocument_CreateElementNS(This->doc_node->nsdoc, &ns, &tag, &dom_element);
nsAString_Finish(&ns);
nsAString_Finish(&tag);
if(NS_FAILED(nsres)) {
WARN("CreateElementNS failed: %08x\n", nsres);
return map_nsresult(nsres);
}
hres = HTMLElement_Create(This->doc_node, (nsIDOMNode*)dom_element, FALSE, &element);
nsIDOMElement_Release(dom_element);
if(FAILED(hres))
return hres;
*newElem = &element->IHTMLElement_iface;
return S_OK;
}
static HRESULT WINAPI HTMLDocument7_createAttributeNS(IHTMLDocument7 *iface, VARIANT *pvarNS,

View File

@ -168,6 +168,25 @@ function test_getElementsByClassName() {
next_test();
}
function test_createElementNS() {
var svg_ns = "http://www.w3.org/2000/svg";
var elem;
elem = document.createElementNS(null, "test");
ok(elem.tagName === "test", "elem.tagName = " + elem.tagName);
elem = document.createElementNS(svg_ns, "test");
ok(elem.tagName === "test", "elem.tagName = " + elem.tagName);
elem = document.createElementNS(svg_ns, "svg");
ok(elem.tagName === "svg", "elem.tagName = " + elem.tagName);
elem = document.createElementNS("test", "svg");
ok(elem.tagName === "svg", "elem.tagName = " + elem.tagName);
next_test();
}
function test_query_selector() {
document.body.innerHTML = '<div class="class1">'
+ '<div class="class1"></div>'
@ -351,6 +370,7 @@ var tests = [
test_textContent,
test_ElementTraversal,
test_getElementsByClassName,
test_createElementNS,
test_head,
test_iframe,
test_anchor,