Follow-up to #2544318: Remove #type => html_tag usages
Problem/Motivation
As part of #2296101: Remove SafeMarkup::set() use in \Drupal\Core\Render\Element\HtmlTag::preRenderHtmlTag(), we identified the potential improvement of removing #type => 'html_tag'
(including dawehner in #4 and catch in #7.
From #38:
[T]he non-test uses [of
#type => 'html_tag'
] in core can be grouped into 2 categories:<head>
elements such as<meta>
,<link>
, and<script>
, and simple combinations where SafeMarkup::format could be used instead._drupal_add_html_head() is listed as deprecated (#2477223: Refactor _drupal_add_html_head, drupal_get_html_head, _drupal_add_html_head_link into the attachments processor, remove from common.inc.), so we may need to postpone on that. In the meantime, we could work on the 6 places where non-head-type tags are using this #type? (One of those places is FilterCaption.php, which has its own use of SafeMarkup).
Proposed resolution
remove the 6 places where non-head-type tags are using #type => 'html_tag'
and
Remove \Drupal\Core\Render\Element\HtmlTag
Remaining tasks
User interface changes
?
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#43 | 2821292-nr-bot.txt | 144 bytes | needs-review-queue-bot |
#37 | interdiff_30-37.txt | 377 bytes | adityasingh |
#37 | 2821292-37.patch | 9.2 KB | adityasingh |
#35 | Screenshot 2020-11-09 at 4.45.19 PM.png | 24.51 KB | anmolgoyal74 |
#33 | 2821292-applied_patch-30.png | 94.71 KB | Abhijith S |
Comments
Comment #2
joelpittetHere's the patch that extends html_tag for a type meta.
Comment #5
joelpittetLeft some thing in there about buttons that wasn't supposed to be there.
Comment #6
poornima.n CreditAttribution: poornima.n as a volunteer and at gai Technologies Pvt Ltd commentedComment #8
joelpittet@poornima.n What is the patch in #6 supposed to help with?
Comment #9
Prashant.cReplacing the occurrences of
#tag => meta
with#type => meta
wherever found.Not replaced the concurrences of
not sure what needs to be done in this case.
Comment #11
poornima.n CreditAttribution: poornima.n as a volunteer and at gai Technologies Pvt Ltd commented@joelpittet Patch #6 was for Replacement of #tag => meta with #type => meta
Comment #12
joelpittet@Prashant.c and @poornima.n the patch I had put in #5 should have actually done all that was needed. Could you explain what further changes you are making to the patch?
Comment #13
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer commented#5 Looks sane to me...
Comment #14
joelpittetThank you @Manuel Garcia
Comment #15
20th CreditAttribution: 20th commented#5 is the correct patch.
#6 is not quite right because the code in
system.module
looks like this after applying it (notice the double#type
key):The issue is quite trivial, and in my opinion, #5 can be accepted as is but I have still changed a couple of things:
meta
element;#noscript
property from documentation ofMeta
class (because meta tag cannot have a value);meta
tag from$voidElements
list inHtmlTag
class, so that its ability to rendermeta
does not look like an undocumented feature.Comment #17
joelpittetThanks for the tests and cleanup in #15 @20th , here's a reroll.
Comment #19
yogeshmpawarComment #20
yogeshmpawarUpdated patch because previous patch failed to apply to 8.4.x branch.
Comment #21
yogeshmpawarAny Update on this issue ?
Comment #22
Manuel Garcia CreditAttribution: Manuel Garcia as a volunteer commentedPatch #20 still applies cleanly, and it makes sense. Can't think of anything else to do here so RTBCing.
Comment #23
star-szrThis is doing more than replacing usages so should probably be retitled (and issue summary updated) accordingly.
Not sure about this change for backwards compatibility. What about people that would still be using #tag => meta? If we want to deprecate that, can we trigger an error when they use #tag => meta so that we can remove it in 9.x?
Since we're extending HtmlTag, the properties should also include #noscript.
Comment #30
shaktikCreated Patch for D9.1 kindly check.
Comment #32
tanubansal CreditAttribution: tanubansal at Salsa Digital commentedPatch #30 works fine on 9.1
RTBC + 1
Comment #33
Abhijith S CreditAttribution: Abhijith S as a volunteer and at Zyxware Technologies commentedApplied patch #30 and its applies cleanly.The #tag => meta is removed with #type => meta ,and also updated in test cases.
Comment #34
Abhijith S CreditAttribution: Abhijith S as a volunteer and at Zyxware Technologies commentedComment #35
anmolgoyal74 CreditAttribution: anmolgoyal74 at OpenSense Labs for DrupalFit commented#30 giving 1 CS issues.
In
lib/Drupal/Core/Render/Element/Meta.php
, I think it should beinstead of
Comment #36
adityasingh CreditAttribution: adityasingh as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedyes it should be
protected static $voidElements = ['meta'];
Comment #37
adityasingh CreditAttribution: adityasingh as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedUpdated patch. Please review.
Comment #40
vikashsoni CreditAttribution: vikashsoni as a volunteer and at Zyxware Technologies commentedApplied patch #30 applied successfully
Thanks for the patch
Comment #43
needs-review-queue-bot CreditAttribution: needs-review-queue-bot as a volunteer commentedThe Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.