Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- dlls/mshtml/htmlelem.c | 30 +++++++++++++++++++++++++----- dlls/mshtml/tests/documentmode.js | 2 -- 2 files changed, 25 insertions(+), 7 deletions(-)
diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index 77dc5c3..8ff4aee 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -1110,15 +1110,35 @@ static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttr }
if(stringify) { - hres = variant_to_nsstr(&AttributeValue, VARIANT_TO_NSSTR_BSTR_DEPEND, &value_str); - if(FAILED(hres)) - return hres; + BOOL object_str = FALSE; + + if(V_VT(&AttributeValue) == VT_DISPATCH) { + if(compat_mode < COMPAT_MODE_IE9) + object_str = TRUE; + else if(compat_mode < COMPAT_MODE_IE10) { + hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, strAttributeName, + lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &dispid); + if(SUCCEEDED(hres) && get_dispid_type(dispid) == DISPEXPROP_BUILTIN) + object_str = TRUE; + } + }
- if((V_VT(&AttributeValue) & ~VT_BYREF) != VT_BSTR) + if(object_str) { + if(!(V_BSTR(&AttributeValue) = SysAllocString(L"[object]"))) + return E_OUTOFMEMORY; + nsAString_InitDepend(&value_str, V_BSTR(&AttributeValue)); needs_free = TRUE; + }else { + hres = variant_to_nsstr(&AttributeValue, VARIANT_TO_NSSTR_BSTR_DEPEND, &value_str); + if(FAILED(hres)) + return hres;
+ if((V_VT(&AttributeValue) & ~VT_BYREF) != VT_BSTR) + needs_free = TRUE; + + nsAString_GetData(&value_str, (const WCHAR**)&V_BSTR(&AttributeValue)); + } V_VT(&AttributeValue) = VT_BSTR; - nsAString_GetData(&value_str, (const WCHAR**)&V_BSTR(&AttributeValue));
if(!V_BSTR(&AttributeValue)) { V_VT(&AttributeValue) = VT_NULL; diff --git a/dlls/mshtml/tests/documentmode.js b/dlls/mshtml/tests/documentmode.js index ee834b2..2ac8823 100644 --- a/dlls/mshtml/tests/documentmode.js +++ b/dlls/mshtml/tests/documentmode.js @@ -1145,7 +1145,6 @@ sync_test("elem_attr", function() {
elem.setAttribute("id", arr); r = elem.getAttribute("id"); - todo_wine_if(v >= 8 && v < 10). ok(r === (v < 8 || v >= 10 ? "3" : "[object]"), "id = " + r); r = elem.removeAttribute("id"); ok(r === (v < 9 ? true : undefined), "id removeAttribute returned " + r); @@ -1196,7 +1195,6 @@ sync_test("elem_attr", function() {
elem.setAttribute("ondblclick", arr); r = elem.getAttribute("ondblclick"); - todo_wine_if(v >= 8 && v < 10). ok(r === (v < 8 ? arr : (v < 10 ? "[object]" : "3")), "ondblclick = " + r); r = elem.removeAttribute("ondblclick"); ok(r === (v < 8 ? false : (v < 9 ? true : undefined)), "ondblclick removeAttribute returned " + r);