Module: wine Branch: master Commit: a68e77d6133bbe60e1d4e6c3e683af549b989bd3 URL: http://source.winehq.org/git/wine.git/?a=commit;h=a68e77d6133bbe60e1d4e6c3e6...
Author: Jacek Caban jacek@codeweavers.com Date: Tue Jul 24 15:55:41 2012 +0200
mshtml: Use proper document node for createElement called on document fragment.
---
dlls/mshtml/htmldoc.c | 10 ++++++++-- dlls/mshtml/tests/dom.c | 10 +++++++++- 2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c index f9e11ce..57d0b31 100644 --- a/dlls/mshtml/htmldoc.c +++ b/dlls/mshtml/htmldoc.c @@ -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; diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index 8907a98..1a1732f 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -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); }