Closed (fixed)
Project:
Drupal core
Version:
8.0.x-dev
Component:
views.module
Priority:
Minor
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Anonymous (not verified)
Created:
15 Feb 2014 at 18:16 UTC
Updated:
9 Mar 2022 at 12:26 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
Anonymous (not verified) commentedComment #2
dawehnerIt would be great for people to fix the issue if you woul have provided a view configuration which results in such an output, but I guess people will be able to figure out.
Comment #3
kirby14 commentedThis fixes it for me. I applied the same logic to the $wrapper_class as well. Views adds a default wrapper class but if you clear it out, it also adds an empty class tag.
Comment #4
kirby14 commentedMissed a new line for coding standards.
Comment #5
kirby14 commentedLast diff added the new line AND unwanted spaces. Time to find a better editor.
Comment #6
dawehnerLet's try to write a patch as well, so this never happens in the future.
Comment #7
kirby14 commentedI assume you mean a test? If so, I'll see what I can do. I'm new to drupal's test framework.
Comment #8
dawehnerUps, yeah indeed.
Comment #9
kirby14 commentedSo we would want a test that verifies we don't have an empty class on any field for all of Views, right? Not just for the HTML list?
Comment #10
lhangea commentedI cannot reproduce the bug.
Here are the steps I took:
1. Installed the latest version of D 8.x
2. Created an article and a basic page
3. Created a view listing published content.
Result: Cannot find any ul html tag on my page (inspected with firebug).
Comment #11
lhangea commentedNever mind. The issue applies if we select the format of the view to be HTML list.
Comment #12
lhangea commentedI reviwed the working patches from #3 and #5 and they work, everything's fine about them but I thought it would be nice to have them both in one .patch file and made a new patch combining those two patches.
Comment #13
amool commentedComment #14
amool commentedPrevious comment submitted by mistake. It was incomplete.
So, This is how I tested the patch. It works!
1. Created sample content of content-type `article`
2. Created a view and selected display as "HTML List"
3. when browsed to the view the html generated is as show:
4. applied patch and then then the html generated is as shown:

5. Under "Format Settings for that view" added `custom-list-class` to "List Class". HTML generated is as shown.

Comment #15
Anonymous (not verified) commentedShouldn't Attribute class handle empty attributes?
Comment #16
tstoecklerRe #15: For some attributes, i.e. data attributes (and others) empty attributes *should* be displayed, it's just that for class it doesn't make any sense.
Comment #17
Anonymous (not verified) commented#16 wouldnt be better to NOT display empty attributes and those attributes that needs to be displayed without value a boolean TRUE would be used as value? At least that makes sense to me.
Comment #18
tstoecklerAgain, that's not necessarily correct.
<div data-foo>is totally correct and wanted markup whereas<div data-foo="whatever">is not as correct/semantic.Comment #19
webchickLooks like this is still in need of an automated test, per #6/8. #14 looks like it has some good steps to reproduce.
Also, minor, but if we could clean this up in the next re-roll:
Should have a space separating "if" from "("
Comment #20
visabhishek commentedAs per #14, patch looks good and working fine , as per #19 i am uploading patch after cleanup.
Comment #21
kirby14 commentedI think the space should be added here as well?
Comment #22
lhangea commentedPatch with correct spacing for if statements.
Comment #23
shkodrava commentedPatch #22 worked for me.
Comment #24
webchickThis still seems to lack a test. It seems like you could take one of the existing tests and check the output to make sure there's no extra class output?
Comment #25
jayeshanandani commentedWorking on tests!
Comment #26
ACF commentedAdded a test to check for this and a patch to with the fix as well.
Comment #28
dawehnerNitpick alarm, sorry. We do use now @file\nContains ... all over the place, but forget to convert some places. anyone wants to volunteer to convert all the other instances?
Just a quick note: you should be able to use ViewUnitTestBase which executes much faster
I guess we want to provide some configured view instead.
This approach of testing is a bit odd, but it certainly works.
Comment #29
smira commentedhere is some initial improvements on the test patch
wanted to implement more of the changes that dawehner suggested but this seems to work as it is a copy of Drupal\views\Tests\Plugin\StyleUnformattedTest
maybe catch me on irc if you think it needs more work and maybe point me in the right direction?
THank you :)
Comment #31
undertext commentedRewrote test. Please review.
Comment #32
undertext commentedAny feedback?
Comment #33
heiket commentedComment #34
heiket commentedTested and works as described:

1) no class was set (no empty class tag) with no class assigned
2) custom classes on row and list came through after they were assigned
I hope this is helpful. Sorry about the screenshots in 2 comments : (. Still getting my head around how to embed those...
(review and testing part of #Drupal8NZ)
Comment #35
alexpottI think we can simply the preprocess function and have less if's by doing something like:
Also lets improve the test to check that adding a class and a wrapper class works as expected since we've changed that code.
Comment #36
undertext commentedThanks for reviewing. Here is new patch.
Comment #37
m1r1k commentedComment #38
star-szrThese comments need spaces after the
//added per https://www.drupal.org/node/1354#inlineComment #39
hussainwebI fixed the comments as per #38. I also changed assertion comments to make them shorter and simpler and made a few other whitespace changes. There is an interdiff attached too.
Comment #40
heiket commentedAssigned to me for re-test > I am going to run another simplytest.me test before re-set to reviewed and tested by community
Comment #41
heiket commentedretested as per #34


without class
with class
working as described! Ta.
Comment #42
alexpottCommitted 0d1b898 and pushed to 8.0.x. Thanks!