Closed (fixed)
Project:
Drupal core
Version:
10.1.x-dev
Component:
javascript
Priority:
Critical
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
30 Sep 2021 at 07:56 UTC
Updated:
12 Feb 2023 at 02:49 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
kostyashupenkoInit patch
1. I also removed a whole
date.es6.jsfile and its compiled version at all, because they were looks like fully created as a polyfill for browser which doesn't have a native datepicker. https://caniuse.com/input-datetime this thing shows that we are talking here mostly about IE11. I have checked mobile Safari under iOS, desktop Chrome, desktop firefox and MS Edge - and everywhere there is native datepicker. I have no time right now for ultra deep tests, but from what i saw we can fully kick that polyfill.2. Same situation about HTML details - looks like we have used modernizr and polyfill and today it was actual only for IE11 (because again -> in other browsers from what i saw HTML details works good by default), so i decided to kick some extra code, not related to modernizr only.
3. About code a-la
if (Modernizr.touchevents) { ... }we may have some custom js-hack instead of it probably, but right now i'm not sure yet how to handle all cases where such construction was removed. Maybe we can hack some of it on css level, there is some@media (hover: none) {}hacks exist.It's anyway init patch still, but already can be tested/reviewed. I did couple of tests on my side and patch works correct looks like.
Comment #3
jeroentComment #4
longwavePlease also don't try to remove date.js or the details polyfill in this issue, keep it scoped to Modernizr only; we have #3256549: Deprecate core/drupal.date asset library in 9.4.0 for the date polyfill and the details polyfill should handled in a separate issue too.
Comment #5
xjmComment #6
xjmThis is another instance where we should deprecate the library first in 9.4.
Comment #7
longwaveI think I was wrong about removing the date and details polyfills, as they do nothing in browsers that support them, which should be all browsers for 10.0.x
However, this patch also removes many calls to
Modernizr.toucheventswhich then go on to handle differences between touch and non-touch devices - we can't just remove this, I think we need a replacement first, or we will be losing some functionality.It might be worth spinning out separate issues to deal with the polyfill removals, as we can do that even if we don't get rid of Modernizr entirely just yet.
Comment #8
longwave#3101922: Find replacement for Modernizr touchevent test and deprecate already exists to replace
Modernizr.touchevents, so I guess we need to do that first.Comment #9
longwaveAlso opened #3269082: Remove HTML5 details collapse polyfill as removing the collapse polyfill seems straightforward.
Comment #10
bnjmnmI updated #3101922: Find replacement for Modernizr touchevent test and deprecate with a proposed solution. It's potentially a pretty quick solution to maintain the existing functionality without Modernizr present.
Comment #11
bnjmnmThe drupal.date library was removed from 10.0 in #3256549: Deprecate core/drupal.date asset library in 9.4.0
To proceed here, we need to take care of #3101922: Find replacement for Modernizr touchevent test and deprecate and #3269082: Remove HTML5 details collapse polyfill
Comment #12
lauriiiI think we could still make progress on planning the specific mechanics for deprecating the global
Modernizrvariable and/or thecore/modernizrlibrary because I believe there is some evidence that this is being used by themes and modules. We need to decide what are the recommended actions for getting rid of the deprecation warnings for anyone extending this. I guess we would want them to be able to rely on this until Drupal 10 since it might be needed for providing the necessary browser support. In Drupal 10, the recommended action would be to just stop relying on these, with the exception that we could encourage folks to stop using #3101922: Find replacement for Modernizr touchevent test and deprecate already in Drupal 9.I'm wondering if we should postpone deprecating Modernizr library and the global variable to Drupal 10, and instead provide a hard coded global
Modernizrvariable in Drupal 10. This would make it easy for modules to continue supporting Drupal 9 without running into deprecation warnings.Comment #13
bnjmnm+1. This means contrib supporting both 9 & 10 can continue to do so without warnings. When 9 is EOL, Modernizr is fully unnecessary (assuming the near-completed touchevents issue lands), so we wouldn't be triggering warnings to remove something that might be necessary to work with a still-supported browser for the version being run.
Comment #14
lauriiiI went through contrib usages of Modernizr and all of them are providing some functionality and loading a polyfill conditionally along the lines of:
I think based on this the approach that I proposed in #12 would make sense because it would keep the responsibility of deciding on whether to load the polyfill or not outside the module. The deciding factors could be whether the module is loaded on Drupal 9 or Drupal 10, but on top of that there could be a module that provides support for IE 11 in Drupal 10, that would override the static object provided by core with one generated by Modernizr.
I think the downside of the approach where we don't trigger deprecation warnings is that it could potentially accidentally make some modules remove support for IE 11. I think that risk exists regardless of what we do on this issue since we are not triggering deprecation warnings for other instances where IE 11 support is being removed because modules could be depending on code that is incompatible with IE 11 without getting any warning.
Based on that, I think keeping the responsibility of the decision to support IE 11 outside of majority of the modules would make sense, and in this instance it would be simple to achieve. I think if we implemented the proposal from #12, we should explicitly document this behavior as part of broader documentation about dropping support for IE 11.
Comment #15
catch#12 makes sense to me if I understand correctly. No deprecation in 9.x. Provide a fake modernizr in 10.x that always returns false (or true? whichever one it is) to make it a no-op with a change record. Deprecate modernizr in 10.x for 11.x as a whole (from 10.1.x onwards).
Comment #16
lauriiiHere's a proof of concept of how this could look like – just to make it a bit easier to grasp what is being proposed here. I didn't remove any of the usages of Modernizr from core in case anyone wants to set breakpoints and confirm that this works as expected.
I understand that this is just a PoC and may be thrown away. I'm happy to implement different approach if there's another approach that is preferred over this. 😊 Marking NR just to get a CI run for the patch – this is not actually a reviewable final patch.
Comment #17
lauriiicspell 😇
Comment #18
xjm+1 for #14 and #15 as well.
Comment #19
xjmCan we also add a comment on the library definition briefly explaining it and mentioning that it will be deprecated in Drupal 10? Since it's a little weird and different from what it was in 9.3.
Comment #20
bnjmnmEven though contrib uses of Modernizr were evaluated in #12, I'm still concerned that the (admittedly appealing) mock Modernizr demoed in #17 could lead to problems if a site is using other aspects of the Modernizr API. The presence of a Modernizr object in the global namespace could prove confusing to sites that are using core's Modernizr to add functionality (such as adding tests for newer features, not just the IE-specific ones core tests for).
While a library_info_alter makes it possible for a site to bring in "real" Modernizr, I'm still concerned about providing a
window.Modernizrthat doesn't deliver the fullModernizr. Although it doesn't appear to be used in contrib, it seems more like something a specific site might do. It seems possible that a high traffic Drupal might extend core's Modernizr either to support additional browsers or to detecting newer features and gracefully integrate them.Within core, all Modernizr D10 use could easily be replaced with a few lines of JS similar to misc/touchevents-test.js to add the classes in
<html>that Modernizr previously added. The library itself could then be deprecated, but since there may be sites using it for detection beyond what Core uses (via a not-internal API), I'd prefer it continue to be regular old full featured Modernizr. It means keeping a dependency around for another Major release, but the alternative seems like it could be rough on sites.Comment #21
longwaveCan we just leave real Modernizr in core for Drupal 10, but remove all our uses of it and deprecate it either immediately or in 10.1? Then anyone who depends on the library still gets the real thing, but nothing in core will load it by default. I am not sure what the mock Modernizr gains us, if we don't use it in core anyway.
Comment #22
catchThat seems like less initial work. I guess the downside is what if the library goes out of support before the EOL of Drupal 10 and then gets an unpatched vulnerability or similar? But it still gets a couple of releases a year, so maybe that's unlikely. I don't know if there's still a big use case for it for other projects that aren't us or if everyone's going to stop using it over the next five years as IE11 support gets dropped across the board.
Comment #23
catchWent ahead and opened #3281559: Remove modernizr usages from core which seems like it can happen now regardless of what else we do here.
Comment #24
lauriiiIt optimizes making it easy for contrib modules to be compatible with both, Drupal 10 and Drupal 9 without introducing changes, and introducing changes to browser support in the lifecycle of Drupal 9. Although it only does that for a the use case of providing polyfills conditionally based on whether certain browser features are available, and doesn't support advanced use cases such as adding custom tests or listening to events.
That raises a good point that there's some risk in having Modernizr object in these advanced use cases. We could have a Drupal 9.4.0 patch that deprecates all of the other APIs but I believe it doesn't fully address this concern since that still leaves room for confusion.
I'm feeling more favorable towards this after concerns raised in #20. I still think it would be unfortunate to not be able to remove this dependency from Drupal 10 in particular because there's always the risk that it might not be supported for the lifetime of Drupal 10. However, I don't think we have been able to come up with a solution that doesn't come with downsides.
Comment #25
nod_once we have collapse not using it, we can deprecate it and remove it from toolbar. not seeing an issue with deprecating in 10.0, unless we want to wait for 10.1 to avoid tripping up folks with yet another deprecation right after they upgraded to 10.0
Comment #26
xjmRescoping to the new planned scope and moving to 10.1.x.
Comment #27
xjmComment #28
lauriiiOpened #3309341: Remove toolbar/toolbar dependency on Modernizr to remove the Toolbar usage since that's a change we would ideally do only in a major release.
Comment #29
longwaveAll child issues are in and only the library definition and some comments remain.
In this patch the library is deprecated and most comments have been updated, except one in the replacement library that states where the library came from, and one in vendor-update.js that I think can stay until we actually remove the library.
Comment #30
catchI don't think it should happen here, but should we open a new issue for this @todo?
Comment #31
bbralaAre we keeping the prefix? If we need to remove the prefix then we need to act fast. If we are ignoring the prefix from now on, the comment could be removed, but i agree with @catch, split it from the deprecation.
Comment #32
longwaveOver in #3269082-19: Remove HTML5 details collapse polyfill @bnjmnm gives three reasons for just removing the @todo and keeping the prefix.
Comment #33
bbralaThanks, that makes total sense.
Comment #34
xjmMoving to the D11 roadmap.
Comment #35
catchAdded a change record and release note.
Comment #36
smustgrave commentedThis issue is being reviewed by the kind folks in Slack, #need-reveiw-queue. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge require as a guide.
Reviewing the patch and everything looks good.
Seems #30 was 31-32 address why removing the prefix is fine now.
Reading the CR everything looks good. Going to mark this but only comment on the CR would it be useful for an example snippet for how contrib can add modernizer to their module?
Comment #37
xjmThere isn't any one standard or best practice for doing so. #2873160: Implement core management of 3rd-party FE libraries is an existing issue to address this problem space for contrib.
Comment #38
xjmComment #39
longwaveUpdated the link in #29 to point to the real change record, leaving as RTBC.
Comment #40
xjmWe have the following remaining references to "modernizr" once this patch is applied:
The dictionary, libraries, cspell,
.eslintrc.json, andvendor-update.jsmentions should be removed in the D11 followup. (Maybe it would make sense to file it as postponed now, so we don't miss those parts?) However, I think that the mention intouchevents-test.jsshould be removed.Comment #41
catchThe touch-events.js mention is the only documentation for that class:
If we want to remove it, we'd need to replace it with something else, but I kind of think it's fine - it's a port of a single feature from modernizr.
Comment #42
longwaveI came to the same conclusion as @catch in #29, I think it's OK to retain the source of the feature.
Comment #43
smustgrave commentedOpened up #3334920: Remove references to modernizer for #40
Comment #44
alexpottCommitted aa373a8 and pushed to 10.1.x. Thanks!
Comment #46
gappleClosed #2848401: [upstream] Modernizr prevents strict CSP as a duplicate