mshtml: Fixed attribute object caching logic.

This commit is contained in:
Jacek Caban 2012-10-22 11:59:10 +02:00 committed by Alexandre Julliard
parent cb131bf030
commit 8b04ab10b9
2 changed files with 21 additions and 10 deletions

View File

@ -2254,7 +2254,6 @@ static inline HRESULT get_domattr(HTMLAttributeCollection *This, DISPID id, LONG
return E_UNEXPECTED;
}
pos++;
hres = HTMLDOMAttribute_Create(This->elem, id, attr);
if(FAILED(hres))
return hres;
@ -2596,20 +2595,22 @@ static HRESULT HTMLAttributeCollection_invoke(DispatchEx *dispex, DISPID id, LCI
switch(flags) {
case DISPATCH_PROPERTYGET: {
HTMLDOMAttribute *iter;
DWORD pos;
id = id-MSHTML_DISPID_CUSTOM_MIN+1;
pos = id-MSHTML_DISPID_CUSTOM_MIN;
LIST_FOR_EACH_ENTRY(iter, &This->attrs, HTMLDOMAttribute, entry) {
if(!(--id))
break;
if(!pos) {
IHTMLDOMAttribute_AddRef(&iter->IHTMLDOMAttribute_iface);
V_VT(res) = VT_DISPATCH;
V_DISPATCH(res) = (IDispatch*)&iter->IHTMLDOMAttribute_iface;
return S_OK;
}
pos--;
}
if(id)
return E_INVALIDARG;
IHTMLDOMAttribute_AddRef(&iter->IHTMLDOMAttribute_iface);
V_VT(res) = VT_DISPATCH;
V_DISPATCH(res) = (IDispatch*)&iter->IHTMLDOMAttribute_iface;
return S_OK;
WARN("invalid arg\n");
return E_INVALIDARG;
}
default:

View File

@ -113,7 +113,16 @@ function test_setAttribute() {
input.setAttribute("checked", "");
ok(input.checked === false, "input.checked = " + input.checked);
}
function test_attribute_collection() {
var div, attr;
document.body.innerHTML = '<div id="divid" class="test"></div>';
div = document.getElementById("divid");
attr = div.attributes["dir"];
ok(attr === div.attributes["dir"], "attr !== div.attributes['dir']");
}
function test_getter_call() {
@ -166,6 +175,7 @@ function runTests() {
test_remove_style_attribute();
test_getter_call();
test_setAttribute();
test_attribute_collection();
test_override_functions();
var r = window.execScript("globalVar = true;");