Skip to content

Remove legacy browser support JS - #1139

Open
stephaniehobson wants to merge 1 commit into
v23/support-cssfrom
v23/support-js
Open

stephaniehobson wants to merge 1 commit into
v23/support-cssfrom
v23/support-js

Conversation

@stephaniehobson

@stephaniehobson stephaniehobson commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Description

Removes the Element.matches() pollyfill, updates MzpSupports.matchMedia, removed a IE9 classList work around.

  • I have documented this change in the design system.
  • I have recorded this change in CHANGELOG.md. (already covered)

Issue

Part of #1084

Testing

Tests are passing. Give the sticky nav and collapsing components footer a glance, I think they're the most affected.

@stephaniehobson
stephaniehobson added this pull request to stack #1146 September 11, 2026 17:21
…1084)

- Removed the Element.matches() IE8 polyfill from utils.js entirely.
  Native Element.prototype.matches is supported in every browser in
  the new matrix; nextUntil() already calls el.matches() directly so
  nothing downstream changes.
- Collapsed the addEventListener-else-addListener MediaQueryList
  fallback in navigation.js, menu.js, and footer.js down to a plain
  addEventListener call. The standard MediaQueryList.addEventListener
  has been supported since Safari 14 / Firefox 55 / Chrome 55 -- fully
  covered by the new matrix -- so the legacy addListener branch never
  runs in any supported browser.
- Bug fix: MzpSupports.matchMedia required
  window.matchMedia('all').addListener -- the *deprecated* legacy
  MediaQueryList API -- to consider matchMedia supported. Any browser
  that removes the deprecated addListener while keeping standard
  matchMedia (as browsers increasingly do) would make this detect
  return false, silently disabling sticky navigation and everything
  else gated on window.MzpSupports.matchMedia (menu.js, footer.js).
  Fixed to check only for matchMedia itself.
- Simplified two IE9 classList-polyfill workarounds in menu.js
  (removing classes one-at-a-time "in the correct order" per
  mozilla/bedrock#6221) to a single
  classList.remove('a', 'b') call -- multi-argument remove() is
  reliable in every supported browser now that the IE9 bug it worked
  around is out of scope.

Left MzpSupports' public API (matchMedia, requestAnimationFrame,
cssFeatureQueries, classList, details, intersectionObserver) and its
consumers' gate checks in place per the v23 plan -- it's a documented
UMD entry point (webpack.entrypoints.js) referenced in
components/details-component/readme.md, so removing it outright is a
separate, bigger breaking-API decision than this cleanup. All six
detects are now unconditionally true for the supported matrix, which
is effectively dead code, but keeping the module intact avoids a
second breaking change bundled into this one.

Didn't add a spec for the matchMedia fix -- supports.js computes each
property once at module-import time via an IIFE, which doesn't fit
this test harness's plain Jasmine-in-real-browser setup without
module-mocking machinery this repo doesn't have. The existing
menu.js/navigation.js/footer.js specs already exercise the changed
addEventListener lines in real Firefox and Chrome (not jsdom), which
is the practical coverage available here.

Stacked on v23/support-css (browser-support CSS cleanup). Part of #1084.

Verified: npm run lint, npm test (47 specs, Firefox + Chrome), and
npm run build-package all pass.
@stephaniehobson stephaniehobson changed the title Remove dead browser-support JS, fix a matchMedia support-detect bug Update JS for new browser support Sep 17, 2026
@stephaniehobson stephaniehobson changed the title Update JS for new browser support Remove legacy browser support JS Sep 17, 2026
@stephaniehobson
stephaniehobson marked this pull request as ready for review September 17, 2026 22:57
@stephaniehobson stephaniehobson added the Needs:Review 👋 Ready for Developer Review label Sep 17, 2026

@knowler knowler left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r+ 🪦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs:Review 👋 Ready for Developer Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants