Move setting of handler attribute to after element is put in document to workaround a bug; b=26402, r=hyatt@netscape.com

This commit is contained in:
law%netscape.com 2000-02-11 15:33:04 +00:00
parent 26a77156ec
commit c21f0c66ad

View File

@ -434,19 +434,6 @@ NS_IMETHODIMP nsBrowserAppCore::CreateMenuItem(
return NS_ERROR_FAILURE;
}
//Set the onaction attribute
nsString menuitemCmd("gotoHistoryIndex(");
menuitemCmd.Append(aIndex);
menuitemCmd += ")";
if (APP_DEBUG) printf("nsBrowserAppCore::CreateMenuItem Setting action handler to %s\n", menuitemCmd.ToNewCString());
nsString attrName("oncommand");
rv = menuItemElement->SetAttribute(attrName, menuitemCmd);
if (!NS_SUCCEEDED(rv)) {
printf("nsBrowserAppCore::CreateMenuItem ERROR setting onaction handler\n");
return NS_ERROR_FAILURE;
}
// Set the hist attribute to true
rv = menuItemElement->SetAttribute(nsString("ishist"), nsString("true"));
if (!NS_SUCCEEDED(rv)) {
@ -470,8 +457,20 @@ NS_IMETHODIMP nsBrowserAppCore::CreateMenuItem(
printf("nsBrowserAppCore::CreateMenuItem ERROR appending menuitem to menu *****\n");
return NS_ERROR_FAILURE;
}
//Set the onaction attribute
nsString menuitemCmd("gotoHistoryIndex(");
menuitemCmd.Append(aIndex);
menuitemCmd += ")";
if (APP_DEBUG) printf("nsBrowserAppCore::CreateMenuItem Setting action handler to %s\n", menuitemCmd.ToNewCString());
nsString attrName("oncommand");
rv = menuItemElement->SetAttribute(attrName, menuitemCmd);
if (!NS_SUCCEEDED(rv)) {
printf("nsBrowserAppCore::CreateMenuItem ERROR setting onaction handler\n");
return NS_ERROR_FAILURE;
}
else
if (APP_DEBUG) printf("nsBrowserAppCore::CreateMenuItem Successfully appended menu item to parent\n");
if (APP_DEBUG) printf("nsBrowserAppCore::CreateMenuItem Successfully appended menu item to parent\n");