mshtml: Use Gecko attributes for getAttribute, setAttribute and removeAttribute implementation in IE8+ mode.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2021-04-23 19:40:14 +02:00 committed by Alexandre Julliard
parent 7eb05c7590
commit 10e7ead350
3 changed files with 61 additions and 8 deletions

View File

@ -871,6 +871,23 @@ static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttr
TRACE("(%p)->(%s %s %08x)\n", This, debugstr_w(strAttributeName), debugstr_variant(&AttributeValue), lFlags);
if(This->dom_element && dispex_compat_mode(&This->node.event_target.dispex) >= COMPAT_MODE_IE8) {
nsAString name_str, value_str;
nsresult nsres;
hres = variant_to_nsstr(&AttributeValue, FALSE, &value_str);
if(FAILED(hres))
return hres;
nsAString_InitDepend(&name_str, strAttributeName);
nsres = nsIDOMElement_SetAttribute(This->dom_element, &name_str, &value_str);
nsAString_Finish(&name_str);
nsAString_Finish(&value_str);
if(NS_FAILED(nsres))
WARN("SetAttribute failed: %08x\n", nsres);
return map_nsresult(nsres);
}
hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, strAttributeName,
(lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive) | fdexNameEnsure, &dispid);
if(FAILED(hres))
@ -927,6 +944,17 @@ static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttr
if(lFlags & ~(ATTRFLAG_CASESENSITIVE|ATTRFLAG_ASSTRING))
FIXME("Unsupported flags %x\n", lFlags);
if(This->dom_element && dispex_compat_mode(&This->node.event_target.dispex) >= COMPAT_MODE_IE8) {
nsAString name_str, value_str;
nsresult nsres;
nsAString_InitDepend(&name_str, strAttributeName);
nsAString_InitDepend(&value_str, NULL);
nsres = nsIDOMElement_GetAttribute(This->dom_element, &name_str, &value_str);
nsAString_Finish(&name_str);
return return_nsstr_variant(nsres, &value_str, 0, AttributeValue);
}
hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, strAttributeName,
lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &dispid);
if(hres == DISP_E_UNKNOWNNAME) {
@ -954,6 +982,9 @@ static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strA
TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(strAttributeName), lFlags, pfSuccess);
if(dispex_compat_mode(&This->node.event_target.dispex) >= COMPAT_MODE_IE8)
return element_remove_attribute(This, strAttributeName);
hres = IDispatchEx_GetDispID(&This->node.event_target.dispex.IDispatchEx_iface, strAttributeName,
lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &id);
if(hres == DISP_E_UNKNOWNNAME) {

View File

@ -622,3 +622,33 @@ sync_test("set_obj", function() {
r = Object.prototype.toString.call(s);
ok(r === "[object Object]", "toString returned " + r);
});
sync_test("elem_attr", function() {
var v = document.documentMode;
var elem = document.createElement("div"), r;
r = elem.getAttribute("class");
ok(r === null, "class attr = " + r);
r = elem.getAttribute("className");
ok(r === (v < 8 ? "" : null), "className attr = " + r);
elem.className = "cls";
r = elem.getAttribute("class");
ok(r === (v < 8 ? null : "cls"), "class attr = " + r);
r = elem.getAttribute("className");
ok(r === (v < 8 ? "cls" : null), "className attr = " + r);
elem.setAttribute("class", "cls2");
ok(elem.className === (v < 8 ? "cls" : "cls2"), "elem.className = " + elem.className);
r = elem.getAttribute("class");
ok(r === "cls2", "class attr = " + r);
r = elem.getAttribute("className");
ok(r === (v < 8 ? "cls" : null), "className attr = " + r);
elem.setAttribute("className", "cls3");
ok(elem.className === (v < 8 ? "cls3" : "cls2"), "elem.className = " + elem.className);
r = elem.getAttribute("class");
ok(r === "cls2", "class attr = " + r);
r = elem.getAttribute("className");
ok(r === "cls3", "className attr = " + r);
});

View File

@ -462,7 +462,6 @@ async_test("animation_frame", function() {
sync_test("title", function() {
var elem = document.createElement("div");
ok(elem.title === "", "div.title = " + elem.title);
todo_wine.
ok(elem.getAttribute("title") === null, "title attribute = " + elem.getAttribute("title"));
elem.title = "test";
ok(elem.title === "test", "div.title = " + elem.title);
@ -473,27 +472,22 @@ sync_test("disabled", function() {
var elem = document.createElement("div");
document.body.appendChild(elem);
ok(elem.disabled === false, "div.disabled = " + elem.disabled);
todo_wine.
ok(elem.getAttribute("disabled") === null, "disabled attribute = " + elem.getAttribute("disabled") + " expected null");
elem.disabled = true;
ok(elem.disabled === true, "div.disabled = " + elem.disabled);
todo_wine.
ok(elem.getAttribute("disabled") === "", "disabled attribute = " + elem.getAttribute("disabled") + " expected \"\"");
elem.disabled = false;
ok(elem.disabled === false, "div.disabled = " + elem.disabled);
todo_wine.
ok(elem.getAttribute("disabled") === null, "disabled attribute = " + elem.getAttribute("disabled") + " expected null");
elem.setAttribute("disabled", "false");
ok(elem.disabled === true, "div.disabled = " + elem.disabled);
todo_wine.
ok(elem.getAttribute("disabled") === "false", "disabled attribute = " + elem.getAttribute("disabled"));
elem.removeAttribute("disabled");
ok(elem.disabled === false, "div.disabled = " + elem.disabled);
todo_wine.
ok(elem.getAttribute("disabled") === null, "disabled attribute = " + elem.getAttribute("disabled") + " expected null");
});
@ -508,11 +502,9 @@ sync_test("hasAttribute", function() {
elem.setAttribute("attr2", "abc");
r = elem.hasAttribute("attr2");
todo_wine.
ok(r === true, "hasAttribute(attr2) returned " + r);
elem.removeAttribute("attr");
r = elem.hasAttribute("attr");
todo_wine.
ok(r === false, "hasAttribute(attr) returned " + r);
});