Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Coming from fixing the CSS Variables po[ln]yfill for IE, i stumbled upon this:
How to reproduce:
* Want to add library CSS/JS browser-conditional like so:
my_library:
js:
run-cssvars-polyfill.js:
browsers: { '!IE': false }
Result:
* CSS/JS is wrapped in a browser-switch comment like this:
<!--[if IE]>
<script src="/modules/contrib/cssvars/polyfill/libraries/css-vars-polyfill.min.js?q16qed"></script>
<![endif]-->
Alas, M$ dropped the conditional script comment tag in 2016 since IE10 (SO). So it seems that the resulting browser switch comments only work up to IE9 (see #2390621: [policy, no patch] Update Drupal's browser support policy on why this is EOL but still supported).
Proposed resolution
* Update docs.
Once we drop IE9,
* Remove the functionality.
* Error out or add warning if developers use it.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#42 | 3095113-42.patch | 2.62 KB | anmolgoyal74 |
Comments
Comment #2
geek-merlinLinked this issue to CSS and JS lib docs for now.
Comment #3
geek-merlinComment #4
gappleIE 9 & 10 support was already dropped in 8.4 #2842298: [policy, no patch] Drop IE9 and IE10 support from Drupal 8.4.x, and this is probably something that the IE9 Compatibility module could maintain support for.
Maybe best to deprecate in D8, and drop in D9?
Comment #5
gappleComment #7
geek-merlin> Maybe best to deprecate in D8, and drop in D9?
Yes, sounds most reasonable then. Patch makes sense.
OK, 1500 failing tests, but that may result from a single usage in the theme.
Comment #8
gappleI think the errors are because classList and/or html5shiv (which use the
browsers
attribute, but are already deprecated) are included on almost every page. Hopefully adding to the skipped deprecation messages should improve the test failures.Comment #9
gappleI've created #3101620: Remove IE conditional comments support in Drupal 10 to handle the removal in D9.
Comment #11
gappleI'm not sure why
testPreRenderHtmlTag()
calledpreRenderConditionalComments()
- I think that can just be removed.Marked
testPreRenderConditionalComments()
as legacy, which I think should resolve that last failure.Comment #12
longwaveThis looks good to me, there is no point keeping this code around if we don't support any of the browsers that can actually use it.
Comment #13
gappleCreated a change record https://www.drupal.org/node/3102997
----
The documentation page for adding CSS / JS to modules doesn't mention the
browsers
property, and the page for adding CSS / JS to themes already includes a note about conditional comments not being supported by IE10+.Comment #14
lauriiiGood catch! We have already passed the deadline to introduce deprecations for removal from Drupal 9. Even though we don't support IE 9 anymore, this is probably something that would make it more difficult for someone else to support IE 9. For that reason, I assume we have to deal with this just like with any other deprecations at this point and target them for removal in Drupal 10. I tagged this for release manager review since they might have thoughts on this.
Nit: There should be extra line change before this line.
I think we usually link to the change record rather than the issue.
Comment #15
MeenakshiG CreditAttribution: MeenakshiG at OpenSense Labs for DrupalFit commentedComment #16
Sahana _N CreditAttribution: Sahana _N commentedPlease review the patch. I followed #14
Comment #19
gappleThe failures for the patches in #15 and #16 are because they didn't update the corresponding message in the skipped deprecations list.
I bumped the version in the patch to 8.8.2 for now, in the optimistic hope that this doesn't need to be delayed.
Comment #20
gapple- Themes which want to use conditional comments to support IE <=9 can still add assets directly in the html.html.twig template, or insert generated markup into html_head (similar to what's needed for inline JavaScript), they just can't rely on the library dependency resolution (which isn't needed for things like html5shiv or classList polyfill).
- For the IE9 Compatibility module to maintain / restore support, my understanding is that it just needs to duplicate the current #pre_render callback.
Comment #21
lauriiiCould we add #20 with some examples to the change record? That would address some of the concerns raised on #14.
Comment #22
lauriiiTalked with @catch and he had a recommended that this would be deprecated from Drupal 10. Unfortunately, it seems like we don't have a decision on how we should do that yet #3088246: [policy, no patch] How to handle Drupal 8.9.x deprecations.
Comment #23
longwaveAs per #3088246: [policy, no patch] How to handle Drupal 8.9.x deprecations this is non critical and unfortunately needs to be deprecated in 9.1 for removal in 10.
Comment #24
catchComment #25
ravi.shankar CreditAttribution: ravi.shankar at OpenSense Labs commentedWorking on this.
Comment #26
ravi.shankar CreditAttribution: ravi.shankar at OpenSense Labs commentedHere I have added reroll of patch #19 and addressed comment #23.
Comment #27
longwaveThanks for updating the version numbers, this looks good to go now.
Comment #28
catchWhat do we need to do to un-suppress the deprecation prior to Drupal 10?
Comment #29
gappleThe suppression was added because of classList and html5shiv, so I think it's no longer needed in 9.x
Comment #30
catchOK let's try to remove it here if possible.
Comment #31
gappleComment #33
gappleMarking a test of JS assets being wrapped in conditional comments as legacy.
Comment #34
gappleoops
Comment #35
longwaveWe should be able to test the deprecation by adding this to one of the tests:
Comment #36
Deepak Goyal CreditAttribution: Deepak Goyal at Srijan | A Material+ Company for Drupal India Association commentedComment #37
Deepak Goyal CreditAttribution: Deepak Goyal at Srijan | A Material+ Company for Drupal India Association commentedHi @longwave
Updated patch please review.
Comment #38
gapple@Deepak Goyal
You applied the
@expectedDeprecation
to the prerender method - it should added to the relevant test method(s) instead.Comment #39
longwaveComment #40
gapple@expectedDeprecation
annotation is deprecated,ExpectDeprecationTrait::expectDeprecation()
method should now be used insteadhttps://www.drupal.org/node/3176667
Comment #41
longwaveComment #42
anmolgoyal74 CreditAttribution: anmolgoyal74 at OpenSense Labs for DrupalFit commentedAddressed #40.
Comment #44
tanubansal CreditAttribution: tanubansal at Salsa Digital commentedTested #42, changes addressed in #40 is visible in #42
Comment #45
gappleComment #47
longwaveRandom fail.
Comment #49
catchCommitted/pushed to 9.2.x and cherry-picked to 9.1.x, thanks!
Comment #51
longwavePublished the change record.