Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AllowBrowser versions #51121

Merged

Conversation

jamiemccarthy
Copy link
Contributor

Motivation / Background

The new AllowBrowser feature was added in #50505 . It permits setting minimum browser versions for an application, defines and documents a :modern version-set as requiring a list of certain features, and adds that option to the default config for new apps.

This PR has been created to make two minor corrections to :modern, one to its versions, one to its documentation.

Detail

  1. In 24264ba, adjust the :modern browser versions to match the description of required features. Specifically, CSS nesting isn't supported by Chrome until 120, Opera until 106 (1, 2).
  2. In ff02912, remove badging from the documentation's list of required features, because it's still a spec that isn't fully implemented by any current browser (1, 2).

Additional information

Personally I'm not convinced this feature will be a good default for new apps, but if it's going to be offered, it should be correct for its stated purpose.

For fun, I benchmarked UserAgent.parse.browser on my laptop and it runs in about 40 microseconds, which is faster than I'd expected. But the runtime require "useragent" added 30 milliseconds to the first request.

The useragent gem was last updated five years ago, and its browser recognition code is all 7 to 9 years old. It seems inappropriate to have a :modern default that doesn't recognize Edge (2015). There's a fork by art19 that recognizes Edge, but it adds 54 other browsers too, so it has 4x the LoC, and its require is 90 milliseconds. Something in-between might be nice.

I made a google spreadsheet listing browser versions that support each of the :modern features listed. The tl;dr is that badges and css nesting are the most-restrictive requirement for every major browser except Firefox (which was late to support css :has).

@zzak
Copy link
Member

zzak commented May 24, 2024

I think this update aligns with the intent here, to cover the supported versions for those list of features mentioned. We probably want to avoid encouraging more PRs to update this list, but that feature-set seems to be the deal breaker.

Initially the badge one confused me but this table makes sense, why it's not fully implemented:

Screenshot from 2024-05-24 12-04-39

@dhh
Copy link
Member

dhh commented May 24, 2024

I'll take the change to Chrome 120 and Opera 106. But badging just being a spec imo doesn't matter. It's a feature that's available on those modern browsers. We don't need 100% support for that to be useful.

Happy to see someone explore a better useragent detector, but that's not a blocker for this.

@rafaelfranca rafaelfranca added this to the 7.2.0 milestone May 24, 2024
@rafaelfranca rafaelfranca force-pushed the jm-fix-allow-browser-versions branch from ff02912 to dc34e29 Compare May 24, 2024 19:50
@rafaelfranca rafaelfranca merged commit 3ccca0c into rails:main May 24, 2024
2 of 3 checks passed
rafaelfranca added a commit that referenced this pull request May 24, 2024
@jamiemccarthy jamiemccarthy deleted the jm-fix-allow-browser-versions branch July 7, 2024 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants