Skip to content

navigator.userAgent will change in Chrome 101, and currently logs an 'issue' in the console #1781

@mikevaux

Description

@mikevaux

I did:

  • Search for if my issue has already been submitted
  • Make sure I'm reporting something precise that needs to be fixed
  • Give my issue a descriptive and concise title
  • Create a minimal working example on JsFiddle or Codepen
    (or gave a link to a demo on the Selectize docs)
  • Indicate precise steps to reproduce in numbers and the result

User Agent strings are being reduced in Chrome 101. While it looks like the elements Selectize relies on will still be available, it might be best to migrate to navigator.userAgentData for safety, and also to avoid an issue being raised in the console every time the library is loaded.

navigator.userAgentData is not supported in all browsers, so would need feature detection before ua detection (!) but could be achieved with something along the lines of:

function uaDetect(platform, re) {
  if (navigator.userAgentData) {
    return platform === navigator.userAgentData.platform;
  }

  return re.test(navigator.userAgent);
}

var IS_MAC = uaDetect("macOS", /Mac/);
// Unsure of the `platform` which is reported for Android
var SUPPORTS_VALIDITY_API = !uaDetect("[Android Platform]", /android/i) && !!document.createElement('input').validity;

Would there be any appetite for this? I can look into the platform which is reported for Android devices and create a PR to update both places in the constants.js file if so?

Relatedly, does Selectize still need to support IE < 11? It would be quite nice to move these variables to consts if not, but const is not supported in IE < 11.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions