<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[42360] trunk/src/wp-includes: Comments: Modernise JavaScript for comment reply links.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/42360">42360</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/42360","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>peterwilsoncc</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2017-12-03 22:36:15 +0000 (Sun, 03 Dec 2017)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Comments: Modernise JavaScript for comment reply links.

Update the comment reply JavaScript to be unobtrusive and use events rather than inline `onclick` attributes. 

Along with bringing the code into the 2010s this prevents an edge-case in which `addComment.moveForm()` could be called before the JavaScript has loaded.

Props peterwilsoncc, bradparbs.
Fixes <a href="https://core.trac.wordpress.org/ticket/31590">#31590</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludescommenttemplatephp">trunk/src/wp-includes/comment-template.php</a></li>
<li><a href="#trunksrcwpincludesjscommentreplyjs">trunk/src/wp-includes/js/comment-reply.js</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludescommenttemplatephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/comment-template.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/comment-template.php        2017-12-03 22:28:33 UTC (rev 42359)
+++ trunk/src/wp-includes/comment-template.php  2017-12-03 22:36:15 UTC (rev 42360)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1667,15 +1667,25 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        $args['login_text']
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><span class="cx" style="display: block; padding: 0 10px">        } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $onclick = sprintf(
-                       'return addComment.moveForm( "%1$s-%2$s", "%2$s", "%3$s", "%4$s" )',
-                       $args['add_below'], $comment->comment_ID, $args['respond_id'], $post->ID
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $data_attributes = array(
+                       'commentid'        => $comment->comment_ID,
+                       'postid'           => $post->ID,
+                       'belowelement'     => $args['add_below'] . '-' . $comment->comment_ID,
+                       'respondelement'   => $args['respond_id'],
</ins><span class="cx" style="display: block; padding: 0 10px">                 );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                $data_attribute_string = '';
+
+               foreach ( $data_attributes as $name => $value ) {
+                       $data_attribute_string .= " data-${name}=\"" . esc_attr( $value ) . "\"";
+               }
+
+               $data_attribute_string = trim( $data_attribute_string );
+
</ins><span class="cx" style="display: block; padding: 0 10px">                 $link = sprintf(
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        "<a rel='nofollow' class='comment-reply-link' href='%s' onclick='%s' aria-label='%s'>%s</a>",
-                       esc_url( add_query_arg( 'replytocom', $comment->comment_ID, get_permalink( $post->ID ) ) ) . '#' . $args['respond_id'],
-                       $onclick,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 "<a rel='nofollow' class='comment-reply-link' href='%s' %s aria-label='%s'>%s</a>",
+                       esc_url( add_query_arg( 'replytocom', $comment->comment_ID ) ) . "#" . $args['respond_id'],
+                       $data_attribute_string,
</ins><span class="cx" style="display: block; padding: 0 10px">                         esc_attr( sprintf( $args['reply_to_text'], $comment->comment_author ) ),
</span><span class="cx" style="display: block; padding: 0 10px">                        $args['reply_text']
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span></span></pre></div>
<a id="trunksrcwpincludesjscommentreplyjs"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/js/comment-reply.js</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/js/comment-reply.js 2017-12-03 22:28:33 UTC (rev 42359)
+++ trunk/src/wp-includes/js/comment-reply.js   2017-12-03 22:36:15 UTC (rev 42360)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5,86 +5,252 @@
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @type {Object}
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-var addComment = {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+var addComment;
+addComment = ( function( window ) {
+       // Avoid scope lookups on commonly used variables.
+       var document = window.document;
+
+       // Settings.
+       var config = {
+               commentReplyClass : 'comment-reply-link',
+               cancelReplyId     : 'cancel-comment-reply-link',
+               commentFormId     : 'commentform',
+               temporaryFormId   : 'wp-temp-form-div',
+               parentIdFieldId   : 'comment_parent',
+               postIdFieldId     : 'comment_post_ID'
+       };
+
+       // Check browser cuts the mustard.
+       var cutsTheMustard = 'querySelector' in document && 'addEventListener' in window;
+
+       /*
+        * Check browser supports dataset.
+        * !! sets the variable to true if the property exists.
+        */
+       var supportsDataset = !! document.body.dataset;
+
+       // For holding the cancel element.
+       var cancelElement;
+
+       // For holding the comment form element.
+       var commentFormElement;
+
+       // The respond element.
+       var respondElement;
+
+       // Initialise the events.
+       init();
+
</ins><span class="cx" style="display: block; padding: 0 10px">         /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @summary Retrieves the elements corresponding to the given IDs.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * Add events to links classed .comment-reply-link.
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @since 2.7.0
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * Searches the context for reply links and adds the JavaScript events
+        * required to move the comment form. To allow for lazy loading of
+        * comments this method is exposed as window.commentReply.init().
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @param {string} commId The comment ID.
-        * @param {string} parentId The parent ID.
-        * @param {string} respondId The respond ID.
-        * @param {string} postId The post ID.
-        * @returns {boolean} Always returns false.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @since 5.0.0
+        *
+        * @param {HTMLElement} context The parent DOM element to search for links.
</ins><span class="cx" style="display: block; padding: 0 10px">          */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        moveForm: function( commId, parentId, respondId, postId ) {
-               var div, element, style, cssHidden,
-                       t           = this,
-                       comm        = t.I( commId ),
-                       respond     = t.I( respondId ),
-                       cancel      = t.I( 'cancel-comment-reply-link' ),
-                       parent      = t.I( 'comment_parent' ),
-                       post        = t.I( 'comment_post_ID' ),
-                       commentForm = respond.getElementsByTagName( 'form' )[0];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function init( context ) {
+               if ( true !== cutsTheMustard ) {
+                       return;
+               }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( ! comm || ! respond || ! cancel || ! parent || ! commentForm ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         // Get required elements.
+               cancelElement = getElementById( config.cancelReplyId );
+               commentFormElement = getElementById( config.commentFormId );
+
+               // No cancel element, no replies.
+               if ( ! cancelElement ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                         return;
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                t.respondId = respondId;
-               postId = postId || false;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         cancelElement.addEventListener( 'touchstart', cancelEvent );
+               cancelElement.addEventListener( 'click',      cancelEvent );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( ! t.I( 'wp-temp-form-div' ) ) {
-                       div = document.createElement( 'div' );
-                       div.id = 'wp-temp-form-div';
-                       div.style.display = 'none';
-                       respond.parentNode.insertBefore( div, respond );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         var links = replyLinks( context );
+               var element;
+
+               for ( var i = 0, l = links.length; i < l; i++ ) {
+                       element = links[i];
+
+                       element.addEventListener( 'touchstart', clickEvent );
+                       element.addEventListener( 'click',      clickEvent );
</ins><span class="cx" style="display: block; padding: 0 10px">                 }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                comm.parentNode.insertBefore( respond, comm.nextSibling );
-               if ( post && postId ) {
-                       post.value = postId;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+        * Return all links classed .comment-reply-link.
+        *
+        * @since 5.0.0
+        *
+        * @param {HTMLElement} context The parent DOM element to search for links.
+        *
+        * @return {HTMLCollection|NodeList|Array}
+        */
+       function replyLinks( context ) {
+               var selectorClass = config.commentReplyClass;
+               var allReplyLinks;
+
+               // childNodes is a handy check to ensure the context is a HTMLElement.
+               if ( ! context || ! context.childNodes ) {
+                       context = document;
</ins><span class="cx" style="display: block; padding: 0 10px">                 }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                parent.value = parentId;
-               cancel.style.display = '';
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                /**
-                * @summary Puts back the comment, hides the cancel button and removes the onclick event.
-                *
-                * @returns {boolean} Always returns false.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( document.getElementsByClassName ) {
+                       // Fastest.
+                       allReplyLinks = context.getElementsByClassName( selectorClass );
+               }
+               else {
+                       // Fast.
+                       allReplyLinks = context.querySelectorAll( '.' + selectorClass );
+               }
+
+               return allReplyLinks;
+       }
+
+       /**
+        * Cancel event handler.
+        *
+        * @since 5.0.0
+        *
+        * @param {Event} event The calling event.
+        */
+       function cancelEvent( event ) {
+               var cancelLink = this;
+               var temporaryFormId  = config.temporaryFormId;
+               var temporaryElement = getElementById( temporaryFormId );
+
+               if ( ! temporaryElement || ! respondElement ) {
+                       // Conditions for cancel link fail.
+                       return;
+               }
+
+               getElementById( config.parentIdFieldId ).value = '0';
+
+               // Move the respond form back in place of the temporary element.
+               temporaryElement.parentNode.replaceChild( respondElement ,temporaryElement );
+               cancelLink.style.display = 'none';
+               event.preventDefault();
+       }
+
+       /**
+        * Click event handler.
+        *
+        * @since 5.0.0
+        *
+        * @param {Event} event The calling event.
+        */
+       function clickEvent( event ) {
+               var replyLink = this,
+                       commId    = getDataAttribute( replyLink, 'belowelement'),
+                       parentId  = getDataAttribute( replyLink, 'commentid' ),
+                       respondId = getDataAttribute( replyLink, 'respondelement'),
+                       postId    = getDataAttribute( replyLink, 'postid'),
+                       follow;
+
+               /*
+                * Third party comments systems can hook into this function via the global scope,
+                * therefore the click event needs to reference the global scope.
</ins><span class="cx" style="display: block; padding: 0 10px">                  */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                cancel.onclick = function() {
-                       var t       = addComment,
-                               temp    = t.I( 'wp-temp-form-div' ),
-                               respond = t.I( t.respondId );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         follow = window.addComment.moveForm(commId, parentId, respondId, postId);
+               if ( false === follow ) {
+                       event.preventDefault();
+               }
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        if ( ! temp || ! respond ) {
-                               return;
-                       }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+        * Backward compatible getter of data-* attribute.
+        *
+        * Uses element.dataset if it exists, otherwise uses getAttribute.
+        *
+        * @since 5.0.0
+        *
+        * @param {HTMLElement} Element DOM element with the attribute.
+        * @param {String}      Attribute the attribute to get.
+        *
+        * @return {String}
+        */
+       function getDataAttribute( element, attribute ) {
+               if ( supportsDataset ) {
+                       return element.dataset[attribute];
+               }
+               else {
+                       return element.getAttribute( 'data-' + attribute );
+               }
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        t.I( 'comment_parent' ).value = '0';
-                       temp.parentNode.insertBefore( respond, temp );
-                       temp.parentNode.removeChild( temp );
-                       this.style.display = 'none';
-                       this.onclick = null;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ /**
+        * Get element by ID.
+        *
+        * Local alias for document.getElementById.
+        *
+        * @since 5.0.0
+        *
+        * @param {HTMLElement} The requested element.
+        */
+       function getElementById( elementId ) {
+               return document.getElementById( elementId );
+       }
+
+       /**
+        * Moves the reply form from its current position to the reply location.
+        *
+        * @since 2.7.0
+        *
+        * @param {String} addBelowId HTML ID of element the form follows.
+        * @param {String} commentId  Database ID of comment being replied to.
+        * @param {String} respondId  HTML ID of 'respond' element.
+        * @param {String} postId     Database ID of the post.
+        */
+       function moveForm( addBelowId, commentId, respondId, postId ) {
+               // Get elements based on their IDs.
+               var addBelowElement = getElementById( addBelowId );
+               respondElement  = getElementById( respondId );
+
+               // Get the hidden fields.
+               var parentIdField   = getElementById( config.parentIdFieldId );
+               var postIdField     = getElementById( config.postIdFieldId );
+               var element, cssHidden, style;
+
+               if ( ! addBelowElement || ! respondElement || ! parentIdField ) {
+                       // Missing key elements, fail.
+                       return;
+               }
+
+               addPlaceHolder( respondElement );
+
+               // Set the value of the post.
+               if ( postId && postIdField ) {
+                       postIdField.value = postId;
+               }
+
+               parentIdField.value = commentId;
+
+               cancelElement.style.display = '';
+               addBelowElement.parentNode.insertBefore( respondElement, addBelowElement.nextSibling );
+
+               /*
+                * This is for backward compatibility with third party commenting systems
+                * hooking into the event using older techniques.
+                */
+               cancelElement.onclick = function(){
</ins><span class="cx" style="display: block; padding: 0 10px">                         return false;
</span><span class="cx" style="display: block; padding: 0 10px">                };
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                /*
-                * Sets initial focus to the first form focusable element.
-                * Uses try/catch just to avoid errors in IE 7- which return visibility
-                * 'inherit' when the visibility value is inherited from an ancestor.
-                */
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         // Focus on the first field in the comment form.
</ins><span class="cx" style="display: block; padding: 0 10px">                 try {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        for ( var i = 0; i < commentForm.elements.length; i++ ) {
-                               element = commentForm.elements[i];
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 for ( var i = 0; i < commentFormElement.elements.length; i++ ) {
+                               element = commentFormElement.elements[i];
</ins><span class="cx" style="display: block; padding: 0 10px">                                 cssHidden = false;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                // Modern browsers.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                         // Get elements computed style.
</ins><span class="cx" style="display: block; padding: 0 10px">                                 if ( 'getComputedStyle' in window ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                        // Modern browsers.
</ins><span class="cx" style="display: block; padding: 0 10px">                                         style = window.getComputedStyle( element );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                                // IE 8.
</del><span class="cx" style="display: block; padding: 0 10px">                                 } else if ( document.documentElement.currentStyle ) {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                                        // IE 8.
</ins><span class="cx" style="display: block; padding: 0 10px">                                         style = element.currentStyle;
</span><span class="cx" style="display: block; padding: 0 10px">                                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -107,21 +273,45 @@
</span><span class="cx" style="display: block; padding: 0 10px">                                // Stop after the first focusable element.
</span><span class="cx" style="display: block; padding: 0 10px">                                break;
</span><span class="cx" style="display: block; padding: 0 10px">                        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                }
+               catch(e) {
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                } catch( er ) {}
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                /*
+                * false is returned for backward compatibility with third party commenting systems
+                * hooking into this function.
+                */
</ins><span class="cx" style="display: block; padding: 0 10px">                 return false;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        },
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @summary Returns the object corresponding to the given ID.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * Add placeholder element.
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * Places a place holder element above the #respond element for
+        * the form to be returned to if needs be.
+        *
</ins><span class="cx" style="display: block; padding: 0 10px">          * @since 2.7.0
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @param {string} id The ID.
-        * @returns {Element} The element belonging to the ID.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @param {HTMLelement} respondElement the #respond element holding comment form.
</ins><span class="cx" style="display: block; padding: 0 10px">          */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        I: function( id ) {
-               return document.getElementById( id );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function addPlaceHolder( respondElement ) {
+               var temporaryFormId  = config.temporaryFormId;
+               var temporaryElement = getElementById( temporaryFormId );
+
+               if ( temporaryElement ) {
+                       // The element already exists, no need to recreate.
+                       return;
+               }
+
+               temporaryElement = document.createElement( 'div' );
+               temporaryElement.id = temporaryFormId;
+               temporaryElement.style.display = 'none';
+               respondElement.parentNode.insertBefore( temporaryElement, respondElement );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-};
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+       return {
+               init: init,
+               moveForm: moveForm
+       };
+})( window );
</ins></span></pre>
</div>
</div>

</body>
</html>