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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

geek-merlin’s picture

Linked this issue to CSS and JS lib docs for now.

geek-merlin’s picture

Issue summary: View changes
gapple’s picture

Title: Browser conditional comments broken » Deprecate & remove IE conditional comments support
Category: Bug report » Task
Issue tags: +IE9
Related issues: +#2842298: [policy, no patch] Drop IE9 and IE10 support from Drupal 8.4.x

IE 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?

gapple’s picture

Status: Needs review » Needs work

The last submitted patch, 5: drupal-3095113-5.patch, failed testing. View results

geek-merlin’s picture

> 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.

gapple’s picture

Status: Needs work » Needs review
FileSize
2.21 KB
1.72 KB

I 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.

gapple’s picture

Title: Deprecate & remove IE conditional comments support » Deprecate IE conditional comments support

I've created #3101620: Remove IE conditional comments support in Drupal 10 to handle the removal in D9.

Status: Needs review » Needs work

The last submitted patch, 8: drupal-3095113-8.patch, failed testing. View results

gapple’s picture

Status: Needs work » Needs review
FileSize
903 bytes
3.24 KB

I'm not sure why testPreRenderHtmlTag() called preRenderConditionalComments() - I think that can just be removed.
Marked testPreRenderConditionalComments() as legacy, which I think should resolve that last failure.

longwave’s picture

Status: Needs review » Reviewed & tested by the community

This 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.

gapple’s picture

Created 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+.

lauriii’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs release manager review

Good 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.

  1. +++ b/core/lib/Drupal/Core/Render/Element/HtmlTag.php
    @@ -112,6 +112,9 @@ public static function preRenderHtmlTag($element) {
    +   * @see https://www.drupal.org/project/drupal/issues/3095113
    

    Nit: There should be extra line change before this line.

  2. +++ b/core/lib/Drupal/Core/Render/Element/HtmlTag.php
    @@ -112,6 +112,9 @@ public static function preRenderHtmlTag($element) {
    +   * @see https://www.drupal.org/project/drupal/issues/3095113
    
    @@ -150,6 +153,8 @@ public static function preRenderConditionalComments($element) {
    +    @trigger_error('Support for IE Conditional Comments is deprecated in drupal:8.8.1 and is removed from drupal:9.0.0. See https://www.drupal.org/project/drupal/issues/3095113', E_USER_DEPRECATED);
    

    I think we usually link to the change record rather than the issue.

MeenakshiG’s picture

Status: Needs work » Needs review
FileSize
3.21 KB
1.13 KB
Sahana _N’s picture

Please review the patch. I followed #14

The last submitted patch, , failed testing. View results

Status: Needs review » Needs work

The last submitted patch, 16: 3095113-15.patch, failed testing. View results

gapple’s picture

Status: Needs work » Needs review
FileSize
3.19 KB
2.35 KB

The 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.

gapple’s picture

- 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.

lauriii’s picture

Could we add #20 with some examples to the change record? That would address some of the concerns raised on #14.

lauriii’s picture

Talked 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.

longwave’s picture

Version: 8.9.x-dev » 9.1.x-dev
Status: Needs review » Needs work

As 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.

catch’s picture

Issue tags: +Drupal 10
ravi.shankar’s picture

Assigned: Unassigned » ravi.shankar

Working on this.

ravi.shankar’s picture

Assigned: ravi.shankar » Unassigned
Status: Needs work » Needs review
FileSize
3.3 KB
2.49 KB

Here I have added reroll of patch #19 and addressed comment #23.

longwave’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for updating the version numbers, this looks good to go now.

catch’s picture

+++ b/core/tests/Drupal/Tests/Listeners/DeprecationListenerTrait.php
@@ -200,6 +200,7 @@ public static function getSkippedDeprecations() {
       'AssertLegacyTrait::buildXPathQuery() is deprecated in drupal:8.2.0 and is removed from drupal:10.0.0. Use $this->assertSession()->buildXPathQuery() instead. See https://www.drupal.org/node/3129738',
       'AssertLegacyTrait::constructFieldXpath() is deprecated in drupal:8.5.0 and is removed from drupal:10.0.0. Use $this->getSession()->getPage()->findField() instead. See https://www.drupal.org/node/3129738',
+      'Support for IE Conditional Comments is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. See https://www.drupal.org/node/3102997',
     ];
   }

What do we need to do to un-suppress the deprecation prior to Drupal 10?

gapple’s picture

The suppression was added because of classList and html5shiv, so I think it's no longer needed in 9.x

catch’s picture

Status: Reviewed & tested by the community » Needs work

OK let's try to remove it here if possible.

gapple’s picture

Status: Needs work » Needs review
FileSize
2.14 KB
967 bytes

Status: Needs review » Needs work

The last submitted patch, 31: drupal-3095113-31.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

gapple’s picture

Status: Needs work » Needs review

Marking a test of JS assets being wrapped in conditional comments as legacy.

gapple’s picture

oops

longwave’s picture

Status: Needs review » Needs work

We should be able to test the deprecation by adding this to one of the tests:

   * @expectedDeprecation Support for IE Conditional Comments is deprecated in drupal:9.1.0 and is removed from drupal:10.0.0. See https://www.drupal.org/node/3102997
Deepak Goyal’s picture

Assigned: Unassigned » Deepak Goyal
Deepak Goyal’s picture

Assigned: Deepak Goyal » Unassigned
Status: Needs work » Needs review
FileSize
2.78 KB
751 bytes

Hi @longwave
Updated patch please review.

gapple’s picture

Status: Needs review » Needs work

@Deepak Goyal
You applied the @expectedDeprecation to the prerender method - it should added to the relevant test method(s) instead.

longwave’s picture

Status: Needs work » Needs review
FileSize
2.55 KB
1.53 KB
gapple’s picture

@expectedDeprecation annotation is deprecated, ExpectDeprecationTrait::expectDeprecation() method should now be used instead

https://www.drupal.org/node/3176667

longwave’s picture

Status: Needs review » Needs work
anmolgoyal74’s picture

Status: Needs work » Needs review
FileSize
2.62 KB
978 bytes

Addressed #40.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

tanubansal’s picture

Tested #42, changes addressed in #40 is visible in #42

gapple’s picture

Status: Needs review » Reviewed & tested by the community

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 42: 3095113-42.patch, failed testing. View results

longwave’s picture

Status: Needs work » Reviewed & tested by the community

Random fail.

  • catch committed a60c3a4 on 9.2.x
    Issue #3095113 by gapple, longwave, ravi.shankar, Deepak Goyal,...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 9.2.x and cherry-picked to 9.1.x, thanks!

  • catch committed f1789c0 on 9.1.x
    Issue #3095113 by gapple, longwave, ravi.shankar, Deepak Goyal,...
longwave’s picture

Published the change record.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.