MozReview: use text instead of html for inline comments (Bug 1314278); r?davidwalsh draft
authorbyron jones <glob@mozilla.com>
Wed, 02 Nov 2016 13:41:25 +0800
changeset 197 80ab969a8c7c12c378d80fcb2af9149af1bd2e0f
parent 191 b81bf3718ac588ca498f8dd03a52dd8bf1b455f6
push idunknown
push userunknown
push dateunknown
reviewersdavidwalsh
bugs1314278
MozReview: use text instead of html for inline comments (Bug 1314278); r?davidwalsh Using HTML for inline comment rendering results in bad formatting if the comment contains multiple paragraphs. Switch to using text instead, which also requires changing how draft comments are rendered to avoid a bug that returns html markup in the comment.text field. MozReview-Commit-ID: LUu65zaHd0a
reviewboard/reviewboard/static/rb/js/views/inlineCommentView_mozreview.js
reviewboard/reviewboard/templates/diffviewer/inline_comments.html
--- a/reviewboard/reviewboard/static/rb/js/views/inlineCommentView_mozreview.js
+++ b/reviewboard/reviewboard/static/rb/js/views/inlineCommentView_mozreview.js
@@ -90,47 +90,40 @@ RB.InlineCommentView = RB.AbstractCommen
         // Generate html.
         function appendCommentHtml(root) {
             _.each(root, function(element) {
                 var comment = element.comment;
                 var hasReplies = element.replies.length !== 0;
                 commentHtml.push(view.commentTemplate({
                     id: comment.comment_id,
                     user_name: comment.user.username,
-                    comment_html: comment.html,
+                    comment_text: comment.text,
                     depth: element.depth,
                     icon_class: view._commentIconClass(
                         comment.issue_opened, comment.issue_status)
                 }));
                 if (hasReplies) {
                     appendCommentHtml(element.replies);
                 }
             });
         }
         appendCommentHtml(comments);
 
         if (this.isDraft) {
             commentHtml.push(view.draftTemplate({
-                user_name: RB.UserSession.instance.get('username')
+                user_name: RB.UserSession.instance.get('username'),
+                comment_text: view.model.get('draftComment').get('text')
             }));
         }
 
         // Add to DOM.
         this.$el
             .html(this.rowTemplate({ commentHtml: commentHtml.join('') }))
             .prop('id', this.cid);
 
-        // Keep draft comment text in sync.
-        if (this.isDraft) {
-            this.$el.find('.draft .comment')
-                .bindProperty('html', this.model.get('draftComment'), 'html', {
-                    elementToModel: false
-                });
-        }
-
         // Hook up click and hover events.
         this.$el
             .click(function() {
                 view.trigger('clicked');
             })
             .hover(
                 function() {
                     _.each(view.contextRows, function($row) {
--- a/reviewboard/reviewboard/templates/diffviewer/inline_comments.html
+++ b/reviewboard/reviewboard/templates/diffviewer/inline_comments.html
@@ -12,21 +12,21 @@
 </script>
 
 <script type="text/template" id="inlineComments-comment">
   <div class="inlineComment" id="c<%- id %>" style="padding-left: <%- 2 + depth * 8 %>px">
     <div class="meta">
       <span class="<%- icon_class %>"></span>
       <span class="user"><%- user_name %></span>
     </div>
-    <div class="comment"><%= comment_html %></div>
+    <div class="comment"><%- comment_text %></div>
   </div>
 </script>
 
 <script type="text/template" id="inlineComments-draft">
   <div class="inlineComment draft">
     <div class="meta">
       <span class="rb-icon rb-icon-datagrid-comment-draft"></span>
       <span class="user"><%- user_name %></span>
     </div>
-    <div class="comment"></div>
+    <div class="comment"><%- comment_text %></div>
   </div>
 </script>