When you add 'class' as an allowed attribute in Basic HTML and save, it changes to class=""
Steps to reproduce:
- Edit the Basic HTML filter
- Add class to the allowed attributes of a tags
- Save
- class is changed to class=""
Screenshot of input before save:

Screenshot after save:

I note that the filter still works; I can still use the class attribute on a tags.
Original summary
---
Hi, sorry, my english is not perfect. Be indulgent.
After a fresh install of Drupal 8.0.5, i try to add some attributes to "a" html tags (title, class, id, rel, target) . This works, but for class attributes, it's save with additionnal string ="" (see attachment). It's added in Basic HTML text format. I do the same with Restricted HTML and it's ok.
Comments
Comment #2
wim leersGood catch!
Comment #3
RemyAroundTown commentedI was able to reproduce this in 8.1. From the configuration screen for a text format, adding class as an attribute to any tag in the allowed tags list results in class="" being saved instead.
Comment #4
hershey.k commentedGoing to try and reproduce and attempt to fix the issue.
Comment #5
chiranjeeb2410 commented@yolker, which file needs to be considered for this fix?
Comment #6
oeklesund commentedThis should prevent the issue.
Comment #7
oeklesund commentedComment #9
chiranjeeb2410 commentedPatch uploaded against 8.1 core as mentioned by @RemyAroundTown in #3.
Review accordingly.
Comment #10
chiranjeeb2410 commentedShould do the trick. Please review.
Comment #11
ethomas08 commentedTesting on D8.6 and am not able to reproduce the bug. The code looks different so it looks like things must have been fixed at some point with updates. Screenshot attached to show that I could save a class added to the "a" in my filter settings.
Comment #12
ethomas08 commentedScreenshot png is called "class_is_saved"
Comment #13
alonaoneill commentedComment #14
pcate commentedI used to have this issue, but like @ethomas08 I tested removing the =“” and reexporting config today with a site running 8.6, and the issue is no longer occurring.
The original config was exported when the site was running 8.4.
Comment #15
kostyashupenkoComment #16
alonaoneill commentedPatch applied on 8.8x!
Comment #17
cilefen commentedComment #20
pameeela commentedI can reproduce this so I updated IS with screenshots.
But as I note in the IS, the filter still works; I can still use the class attribute on a tags, so I am not sure that this needs to be fixed? It doesn't seem to be causing any problems.
Comment #21
pameeela commentedComment #23
ranjith_kumar_k_u commentedThe last patch failed to apply on 9.2 ,re-rolled for 9.2

Comment #25
quietone commented@ranjith_kumar_k_u, thanks for your interest in this issue. The latest patch didn't pass the coding standards check. Have a look at the instructions for running the coding standard checks locally so you can be sure the tests will run before uploading a patch. It also has the advantage of saving resources, including money, for the Drupal association. There are real costs for running the tests. And add an interdiff or a diff when doing a reroll. That will make it easier for the reviewer.
Comment #26
yedhukrishnan.p@valuebound.com commentedI could not find any coding standard issues apart from the one that I have attached as screenshot image. Please review.
Comment #27
jofitzInclude es6 changes in patch
Comment #28
gauravvvv commentedPatch added, Interdiff attached for patch 26_28.
Comment #29
longwaveThe ES6 code fails our style guidelines:
Comment #30
vsujeetkumar commentedFixed the ES6 code fails, Please have a look.
Comment #31
longwaveThanks. I guess this needs a functional JavaScript test to ensure we don't break it again in the future. There is already a JS test for the HTML filter so it should be possible to extend that.
Comment #32
vsujeetkumar commentedAdded Tests, Please have a look.
Comment #35
smustgrave commentedBelieve this is a duplicate of https://www.drupal.org/project/drupal/issues/2710427#comment-14627888 or also being solved over there. Could someone confirm?
Comment #36
darvanenI agree with @smustgrave, this is a duplicate of #2710427: Broken "Allowed Tags" updating: after all values for an attribute are allowed, it should not be overridden to allow only certain attribute values.
I would normally favour the issue that was opened earlier (this one) but in this case the other ticket has a more fleshed out issue summary and a good deal more recent discussion, so closing this ticket instead.
We have asked in #bugsmash for credit to be transferred from this ticket to that one.
Comment #37
quietone commentedMoving credit