This is perhaps a minor point, and I only noticed it because I wanted to quickly hide a few fields that site editors weren't ever going to use. But the Twitter cards–related fields have CSS classes on their divs that are invalid. For instance:
form-item-metatags-twitter:creator:id-value
form-item-metatags-twitter:image-value
form-item-metatags-twitter:image:width-value
form-item-metatags-twitter:player:stream:content-type-value
None of those colons are valid in the CSS class names. I'm guessing the field names are just being converted to class names without replacing those colons with hyphens (or something).
Comment | File | Size | Author |
---|---|---|---|
#6 | metatag-n2058569-6.patch | 1.24 KB | DamienMcKenna |
Comments
Comment #1
rootworkActually I just noticed the Dublin Core fields have invalid class names too:
form-item-metatags-dcterms.subject-value
form-item-metatags-dcterms.contributor-value
form-item-metatags-dcterms.format-value
(etc.)
The periods aren't valid in CSS class names (as they have a functional purpose in stylesheets).
Comment #2
rootworkI did some more digging. It looks like it's Drupal's formbuilder itself, which only replaces the characters " ", "_", "[", and "]".
I looked through metatag.module, metatag.vertical-tabs.js, and metatag_twitter_cards.metatag.inc and couldn't figure out where it's being called precisely (this isn't my strong suit).
For reference, I'm attaching what would be a patch of the core formbuilder. If Metatag's maintainers think this should actually be handled in core itself, I'll change the project, but really this is just to move this issue along and provide the context so it can be addressed in Metatag.
Comment #3
DamienMcKennaComment #4
DamienMcKennaCorrecting the status - the patch isn't for Metatag.
Comment #5
DamienMcKennaComment #6
DamienMcKennaThis could be handled in Metatag by assigning a #name attribute to the form fields, right?
Comment #7
DamienMcKennaComment #10
DamienMcKennaThe change breaks all the things. Ugh.
Comment #11
DamienMcKennaWe might have to rename all of the meta tags in order to fix this, and I'd prefer not to have to do that.
Comment #12
Heine CreditAttribution: Heine commentedAccording to the CSS spec:
Either one of the following selectors is valid:
Comment #13
rootworkI guess, but is that really where we want to leave it? We don't want to just replace those characters?
I suppose if "breaks all the things" is the only other option then the answer is that we leave it. But I don't know any other contrib modules, certainly not as big as Metatag, that require themers to escape the class names it outputs.
Comment #14
DamienMcKenna@rootwork: I really do sympathize with the issue. I've opened a core issue to see if we can fix the issue there: #2741917: theme_form_element can result in field classes that contain invalid/inconvenient characters
Comment #15
rootworkThanks! I'll follow over there.
Comment #16
rootworkIf anyone else encounters this issue, I've posted an updated core patch at #2741917: theme_form_element can result in field classes that contain invalid/inconvenient characters.