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

mshtml: Use proper document node for createElement called on document fragment.

parent b1d063b1
......@@ -1022,17 +1022,23 @@ static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTa
IHTMLElement **newElem)
{
HTMLDocument *This = impl_from_IHTMLDocument2(iface);
HTMLDocumentNode *doc_node;
nsIDOMHTMLElement *nselem;
HTMLElement *elem;
HRESULT hres;
TRACE("(%p)->(%s %p)\n", This, debugstr_w(eTag), newElem);
hres = create_nselem(This->doc_node, eTag, &nselem);
/* Use owner doc if called on document fragment */
doc_node = This->doc_node;
if(!doc_node->nsdoc)
doc_node = doc_node->node.doc;
hres = create_nselem(doc_node, eTag, &nselem);
if(FAILED(hres))
return hres;
hres = HTMLElement_Create(This->doc_node, (nsIDOMNode*)nselem, TRUE, &elem);
hres = HTMLElement_Create(doc_node, (nsIDOMNode*)nselem, TRUE, &elem);
nsIDOMHTMLElement_Release(nselem);
if(FAILED(hres))
return hres;
......
......@@ -6246,10 +6246,10 @@ static IHTMLDocument2 *create_docfrag(IHTMLDocument2 *doc)
static void test_docfrag(IHTMLDocument2 *doc)
{
IHTMLDocument2 *frag, *owner_doc, *doc_node;
IHTMLElement *div, *body, *br;
IHTMLElementCollection *col;
IHTMLLocation *location;
IHTMLDocument2 *frag;
HRESULT hres;
static const elem_type_t all_types[] = {
......@@ -6288,6 +6288,14 @@ static void test_docfrag(IHTMLDocument2 *doc)
test_elem_collection((IUnknown*)col, all_types, sizeof(all_types)/sizeof(all_types[0]));
IHTMLElementCollection_Release(col);
div = test_create_elem(frag, "div");
owner_doc = get_owner_doc((IUnknown*)div);
doc_node = get_doc_node(doc);
ok(iface_cmp((IUnknown*)owner_doc, (IUnknown*)doc_node), "owner_doc != doc_node\n");
IHTMLDocument2_Release(doc_node);
IHTMLDocument2_Release(owner_doc);
IHTMLElement_Release(div);
IHTMLDocument2_Release(frag);
}
......
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