Ticket #29974: 29974.8.patch
File 29974.8.patch, 2.4 KB (added by , 9 years ago) |
---|
-
src/wp-includes/js/comment-reply.js
1 1 var addComment = { 2 2 moveForm: function( commId, parentId, respondId, postId ) { 3 var div, element, node,style, cssHidden,3 var div, element, style, cssHidden, 4 4 t = this, 5 5 comm = t.I( commId ), 6 6 respond = t.I( respondId ), … … 47 47 return false; 48 48 }; 49 49 50 // Set initial focus to the first form focusable element. 50 /* 51 * Set initial focus to the first form focusable element. 52 * Try/catch used just to avoid errors in IE 7- which return visibility 53 * 'inherit' when the visibility value is inherited from an ancestor. 54 */ 51 55 try { 52 56 for ( var i = 0; i < commentForm.elements.length; i++ ) { 53 57 element = commentForm.elements[i]; 58 cssHidden = false; 54 59 55 // Skip form elements that are hidden or disabled. 56 if ( 'hidden' === element.type || element.hasAttribute( 'disabled' ) ) { 57 continue; 60 // Modern browsers. 61 if ( 'getComputedStyle' in window ) { 62 style = window.getComputedStyle( element ); 63 // IE 8. 64 } else if ( document.documentElement.currentStyle ) { 65 style = element.currentStyle; 58 66 } 59 67 60 if ( 'getComputedStyle' in window ) { 61 node = element; 62 cssHidden = false; 68 /* 69 * For display none, do the same thing jQuery does. For visibility, 70 * check the element computed style since browsers are already doing 71 * the job for us. In fact, the visibility computed style is the actual 72 * computed value and already takes into account the element ancestors. 73 */ 74 if ( ( element.offsetWidth <= 0 && element.offsetHeight <= 0 ) || style.visibility === 'hidden' ) { 75 cssHidden = true; 76 } 63 77 64 while( node.parentNode ) { 65 style = window.getComputedStyle( node ); 66 67 if ( style.display === 'none' || style.visibility === 'hidden' ) { 68 cssHidden = true; 69 break; 70 } 71 72 node = node.parentNode; 73 } 74 75 if ( cssHidden ) { 76 continue; 77 } 78 // Skip form elements that are hidden or disabled. 79 if ( 'hidden' === element.type || element.disabled || cssHidden ) { 80 continue; 78 81 } 79 82 80 83 element.focus(); … … 81 84 // Stop after the first focusable element. 82 85 break; 83 86 } 87 84 88 } catch( er ) {} 85 89 86 90 return false;