Make WordPress Core

Opened 13 years ago

Closed 13 years ago

Last modified 3 years ago

#9301 closed defect (bug) (fixed)

no classes on div-coment in Walker_Comment::start_el()

Reported by: docwhat Owned by:
Milestone: 2.8 Priority: normal
Severity: normal Version: 2.7
Component: Template Keywords: has-patch tested
Focuses: Cc:

Description

There are no classes on Walker_Comment::start_el() when it creates a <div id="div-comment-NNNN"> node.

This makes using CSS target that node pretty hard if not impossible across browsers.

Ideally, it would have a class like "comment-body".

This is a feature aid semantic markup.

Change History (7)

#1 @docwhat
13 years ago

Example Patch

diff --git a/wp-includes/comment-template.php b/wp-includes/comment-template.php
index a4a126b..49cdfc1 100644
--- a/wp-includes/comment-template.php
+++ b/wp-includes/comment-template.php
@@ -1221,3 +1221,3 @@ class Walker_Comment extends Walker {
                <?php if ( 'ul' == $args['style'] ) : ?>
-               <div id="div-comment-<?php comment_ID() ?>">
+               <div id="div-comment-<?php comment_ID() ?>" class="comment-body">
                <?php endif; ?>

#2 @docwhat
13 years ago

  • Keywords has-patch added

#3 @Viper007Bond
13 years ago

Wouldn't using the parent element which has comment_class() on it work?

#4 @docwhat
13 years ago

It would have before we added the "Reply" and nested comments. But now the markup can change, on the fly, from (this is from memory, so the classes might be wrong):

<li class="comment">
  <div id="div-comment-NN" />
</li>

to

<li class="comment">
  <div id="div-comment-NN" />
  <div id="response" />
</li>

So you can't use a rule like:

.comment > div { ... style the body of the comment ... }

... without getting the reply box, too.

Before this change, I'd just use css like this:

.comment { border: 1px solid blue; }

But the box will bound the replies too; which isn't what I wanted.

Ciao!

#5 @Denis-de-Bernardy
13 years ago

  • Component changed from General to Template
  • Keywords tested added
  • Milestone changed from Unassigned to 2.8
  • Version set to 2.7

#6 @ryan
13 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [10961]) Add comment-body class. Props docwhat. fixes #9301

This ticket was mentioned in Slack in #core-media by antpb. View the logs.


3 years ago

Note: See TracTickets for help on using tickets.