Commit e3b9db5a authored by Gabriel Ivăncescu's avatar Gabriel Ivăncescu Committed by Alexandre Julliard
Browse files

mshtml: Implement removeAttributeNS for Elements.



Signed-off-by: Gabriel Ivăncescu's avatarGabriel Ivăncescu <gabrielopcode@gmail.com>
parent c54edb2b
......@@ -4886,8 +4886,26 @@ static HRESULT WINAPI HTMLElement6_setAttributeNS(IHTMLElement6 *iface, VARIANT
static HRESULT WINAPI HTMLElement6_removeAttributeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR strAttributeName)
{
HTMLElement *This = impl_from_IHTMLElement6(iface);
FIXME("(%p)->(%s %s)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName));
return E_NOTIMPL;
nsAString ns_str, name_str;
nsresult nsres;
HRESULT hres;
TRACE("(%p)->(%s %s)\n", This, debugstr_variant(pvarNS), debugstr_w(strAttributeName));
if(!This->dom_element) {
FIXME("No dom_element\n");
return E_NOTIMPL;
}
hres = variant_to_nsstr(pvarNS, FALSE, &ns_str);
if(FAILED(hres))
return hres;
nsAString_InitDepend(&name_str, strAttributeName);
nsres = nsIDOMElement_RemoveAttributeNS(This->dom_element, &ns_str, &name_str);
nsAString_Finish(&ns_str);
nsAString_Finish(&name_str);
return map_nsresult(nsres);
}
static HRESULT WINAPI HTMLElement6_getAttributeNodeNS(IHTMLElement6 *iface, VARIANT *pvarNS, BSTR name, IHTMLDOMAttribute2 **ppretAttribute)
......@@ -6934,6 +6952,35 @@ static HRESULT IHTMLElement6_setAttributeNS_hook(DispatchEx *dispex, WORD flags,
return hres;
}
static HRESULT IHTMLElement6_removeAttributeNS_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
{
VARIANT args[2];
HRESULT hres;
DISPPARAMS new_dp = { args, NULL, 2, 0 };
if(!(flags & DISPATCH_METHOD) || dp->cArgs < 2 || dp->cNamedArgs)
return S_FALSE;
switch(V_VT(&dp->rgvarg[dp->cArgs - 1])) {
case VT_EMPTY:
case VT_BSTR:
case VT_NULL:
return S_FALSE;
default:
break;
}
hres = change_type(&args[1], &dp->rgvarg[dp->cArgs - 1], VT_BSTR, caller);
if(FAILED(hres))
return hres;
args[0] = dp->rgvarg[dp->cArgs - 2];
hres = dispex_call_builtin(dispex, DISPID_IHTMLELEMENT6_REMOVEATTRIBUTENS, &new_dp, res, ei, caller);
VariantClear(&args[1]);
return hres;
}
static HRESULT IHTMLElement6_setAttribute_hook(DispatchEx *dispex, WORD flags, DISPPARAMS *dp,
VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
{
......@@ -6972,6 +7019,7 @@ void HTMLElement_init_dispex_info(dispex_data_t *info, compat_mode_t mode)
static const dispex_hook_t elem6_ie10_hooks[] = {
{DISPID_IHTMLELEMENT6_GETATTRIBUTENS, IHTMLElement6_getAttributeNS_hook},
{DISPID_IHTMLELEMENT6_SETATTRIBUTENS, IHTMLElement6_setAttributeNS_hook},
{DISPID_IHTMLELEMENT6_REMOVEATTRIBUTENS, IHTMLElement6_removeAttributeNS_hook},
{DISPID_IHTMLELEMENT6_IE9_SETATTRIBUTE, IHTMLElement6_setAttribute_hook},
{DISPID_UNKNOWN}
};
......
......@@ -1480,6 +1480,7 @@ sync_test("elem_attrNS", function() {
ok(r === "", "specialspace spec:align (non-NS) = " + r);
r = elem.getAttributeNS(specialspace_ns, "align");
ok(r === "left", "specialspace align (non-NS) = " + r);
elem.removeAttributeNS(null, "spec:align");
elem.setAttribute("emptynsattr", "none");
elem.setAttributeNS("", "emptynsattr", "test");
......@@ -1498,6 +1499,30 @@ sync_test("elem_attrNS", function() {
r = elem.getAttributeNS(specialspace_ns, "emptynsattr");
ok(r === "ns", "emptynsattr specialspace ns = " + r);
elem.removeAttributeNS("", "emptynsattr");
r = elem.getAttribute("emptynsattr");
ok(r === "ns", "emptynsattr without NS after remove = " + r);
r = elem.getAttributeNS(specialspace_ns, "emptynsattr");
ok(r === "ns", "emptynsattr specialspace ns after empty remove = " + r);
elem.setAttribute("emptynsattr", "test");
r = elem.getAttribute("emptynsattr");
ok(r === "test", "emptynsattr without NS after re-set = " + r);
r = elem.getAttributeNS(specialspace_ns, "emptynsattr");
ok(r === "test", "emptynsattr specialspace ns after empty re-set = " + r);
elem.removeAttribute("emptynsattr");
r = elem.getAttribute("emptynsattr");
ok(r === null, "emptynsattr without NS after non-NS remove = " + r);
r = elem.getAttributeNS(specialspace_ns, "emptynsattr");
ok(r === "", "emptynsattr specialspace ns after non-NS remove = " + r);
elem.setAttributeNS(specialspace_ns, "emptynsattr", "ns");
elem.removeAttributeNS(svg_ns, "emptynsattr");
r = elem.getAttributeNS(specialspace_ns, "emptynsattr");
ok(r === "ns", "emptynsattr specialspace ns after wrong NS remove = " + r);
r = elem.getAttributeNS(specialspace_ns, "emptynsattr");
ok(r === "ns", "emptynsattr specialspace ns after remove = " + r);
var ns = {};
ns.toString = function() { return "toString namespace"; }
ns.valueOf = function() { return "valueOf namespace"; }
......@@ -1516,16 +1541,23 @@ sync_test("elem_attrNS", function() {
r = elem.getAttributeNS(svg_ns, "testattr");
ok(r === "3", "testattr = " + r);
ok(elem.testattr === undefined, "elem.testattr = " + elem.testattr);
elem.removeAttributeNS(svg_ns, "testattr");
r = elem.getAttributeNS(svg_ns, "testattr");
ok(r === "", "testattr after remove = " + r);
arr.toString = function() { return 42; }
elem.setAttributeNS(svg_ns, "testattr", arr);
r = elem.getAttributeNS(svg_ns, "testattr");
ok(r === "42", "testattr with custom toString = " + r);
elem.removeAttributeNS(svg_ns, "testattr");
r = elem.getAttributeNS(svg_ns, "testattr");
ok(r === "", "testattr with custom toString after remove = " + r);
arr.valueOf = function() { return "arrval"; }
elem.setAttributeNS(svg_ns, "testattr", arr);
r = elem.getAttributeNS(svg_ns, "testattr");
ok(r === "42", "testattr with custom valueOf = " + r);
elem.removeAttributeNS(svg_ns, "testattr");
elem.setAttributeNS(svg_ns, "boolattr", true);
r = elem.getAttributeNS(svg_ns, "boolattr");
......
Supports Markdown
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