Skip to content
Browse files

javascript MDL-24521 Fixed confirm dialog bug. Kudos to John Anderson…

… for his work on the patch and James Brisland for help testing.
  • Loading branch information...
1 parent c63ebd4 commit 712b55e1ba8ec0425428d95989cf188a51a9d446 Sam Hemelryk committed Jan 5, 2011
Showing with 10 additions and 8 deletions.
  1. +10 −8 lib/javascript-static.js
View
18 lib/javascript-static.js
@@ -262,15 +262,17 @@ M.util.show_confirm_dialog = function(e, args) {
return;
}
- if (target.get('tagName').toLowerCase() == 'a') {
+ var targetancestor = null,
+ targetform = null;
+
+ if (target.test('a')) {
window.location = target.get('href');
- } else if (target.get('tagName').toLowerCase() == 'input') {
- var parentelement = target.get('parentNode');
- while (parentelement.get('tagName').toLowerCase() != 'form' && parentelement.get('tagName').toLowerCase() != 'body') {
- parentelement = parentelement.get('parentNode');
- }
- if (parentelement.get('tagName').toLowerCase() == 'form') {
- parentelement.submit();
+ } else if ((targetancestor = target.ancestor('a')) !== null) {
+ window.location = targetancestor.get('href');
+ } else if (target.test('input')) {
+ targetform = target.ancestor('form');
+ if (targetform && targetform.submit) {
+ targetform.submit();
}
} else if (M.cfg.developerdebug) {
alert("Element of type " + target.get('tagName') + " is not supported by the M.util.show_confirm_dialog function. Use A or INPUT");

0 comments on commit 712b55e

Please sign in to comment.
Something went wrong with that request. Please try again.