diff --git a/dlls/jscript/dispex.c b/dlls/jscript/dispex.c index d7ff77d0c45..1b7ae50843d 100644 --- a/dlls/jscript/dispex.c +++ b/dlls/jscript/dispex.c @@ -1498,6 +1498,49 @@ HRESULT disp_delete(IDispatch *disp, DISPID id, BOOL *ret) return S_OK; } +HRESULT disp_delete_name(script_ctx_t *ctx, IDispatch *disp, jsstr_t *name, BOOL *ret) +{ + IDispatchEx *dispex; + jsdisp_t *jsdisp; + HRESULT hres; + + jsdisp = iface_to_jsdisp((IUnknown*)disp); + if(jsdisp) { + dispex_prop_t *prop; + + *ret = TRUE; + hres = find_prop_name(jsdisp, string_hash(name->str), name->str, &prop); + if(prop) + hres = delete_prop(prop); + else + hres = DISP_E_MEMBERNOTFOUND; + + jsdisp_release(jsdisp); + return hres; + } + + hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex); + if(SUCCEEDED(hres)) { + BSTR bstr; + + bstr = SysAllocStringLen(name->str, jsstr_length(name)); + if(bstr) { + hres = IDispatchEx_DeleteMemberByName(dispex, bstr, make_grfdex(ctx, fdexNameCaseSensitive)); + SysFreeString(bstr); + *ret = TRUE; + }else { + hres = E_OUTOFMEMORY; + } + + IDispatchEx_Release(dispex); + }else { + hres = S_OK; + ret = FALSE; + } + + return hres; +} + HRESULT jsdisp_is_own_prop(jsdisp_t *obj, const WCHAR *name, BOOL *ret) { dispex_prop_t *prop; diff --git a/dlls/jscript/engine.c b/dlls/jscript/engine.c index 20791bfc078..3fedea1c4fc 100644 --- a/dlls/jscript/engine.c +++ b/dlls/jscript/engine.c @@ -1592,7 +1592,6 @@ static HRESULT interp_mod(exec_ctx_t *ctx) static HRESULT interp_delete(exec_ctx_t *ctx) { jsval_t objv, namev; - IDispatchEx *dispex; IDispatch *obj; jsstr_t *name; BOOL ret; @@ -1617,25 +1616,7 @@ static HRESULT interp_delete(exec_ctx_t *ctx) return hres; } - hres = IDispatch_QueryInterface(obj, &IID_IDispatchEx, (void**)&dispex); - if(SUCCEEDED(hres)) { - BSTR bstr; - - bstr = SysAllocStringLen(name->str, jsstr_length(name)); - if(bstr) { - hres = IDispatchEx_DeleteMemberByName(dispex, bstr, make_grfdex(ctx->script, fdexNameCaseSensitive)); - SysFreeString(bstr); - ret = TRUE; - }else { - hres = E_OUTOFMEMORY; - } - - IDispatchEx_Release(dispex); - }else { - hres = S_OK; - ret = FALSE; - } - + hres = disp_delete_name(ctx->script, obj, name, &ret); IDispatch_Release(obj); jsstr_release(name); if(FAILED(hres)) diff --git a/dlls/jscript/jscript.h b/dlls/jscript/jscript.h index 147cc1af453..69ac417c4f3 100644 --- a/dlls/jscript/jscript.h +++ b/dlls/jscript/jscript.h @@ -276,6 +276,7 @@ HRESULT jsdisp_propget_name(jsdisp_t*,LPCWSTR,jsval_t*) DECLSPEC_HIDDEN; HRESULT jsdisp_get_idx(jsdisp_t*,DWORD,jsval_t*) DECLSPEC_HIDDEN; HRESULT jsdisp_get_id(jsdisp_t*,const WCHAR*,DWORD,DISPID*) DECLSPEC_HIDDEN; HRESULT disp_delete(IDispatch*,DISPID,BOOL*) DECLSPEC_HIDDEN; +HRESULT disp_delete_name(script_ctx_t*,IDispatch*,jsstr_t*,BOOL*); HRESULT jsdisp_delete_idx(jsdisp_t*,DWORD) DECLSPEC_HIDDEN; HRESULT jsdisp_is_own_prop(jsdisp_t*,const WCHAR*,BOOL*) DECLSPEC_HIDDEN; HRESULT jsdisp_is_enumerable(jsdisp_t*,const WCHAR*,BOOL*) DECLSPEC_HIDDEN;