Skip to content

Remove dead browser-support JS, fix a matchMedia support-detect bug - #1139

Draft
stephaniehobson wants to merge 2 commits into
v23/support-cssfrom
v23/support-js
Draft

stephaniehobson wants to merge 2 commits into
v23/support-cssfrom
v23/support-js

Conversation

@stephaniehobson

Copy link
Copy Markdown
Contributor

Description

Removes JS that's dead weight under the new browser support matrix (#1084), and fixes a real bug found along the way.

  • Removed the Element.matches() IE8 polyfill from utils.js entirely.
  • Collapsed the addEventListener-else-addListener MediaQueryList fallback in navigation.js, menu.js, and footer.js down to a plain addEventListener call.
  • Bug fix: MzpSupports.matchMedia required window.matchMedia('all').addListener — the deprecated legacy MediaQueryList API — to consider matchMedia supported. Any browser that removes the deprecated method while keeping standard matchMedia would make this detect return false, silently disabling sticky navigation and everything else gated on it. Fixed to check only for matchMedia itself.
  • Simplified two IE9 classList-polyfill workarounds in menu.js to a single classList.remove('a', 'b') call.

MzpSupports's public API is left intact — it's a documented UMD entry point, so removing it is a separate, bigger breaking-API decision than this cleanup.

  • I have documented this change in the design system.
  • I have recorded this change in CHANGELOG.md.

Issue

Part of #1084

Testing

npm run lint, npm test (47 specs, Firefox + Chrome), npm run build-package all pass.

Everything here is unconditionally true for Firefox ESR, Safari 15.6+,
and evergreen browsers, so the feature-query gates and legacy prefixes
around it are dead weight.

- Unwrapped @supports (position: sticky) in _navigation.scss and
  @supports (display: flex) in _menu.scss. The menu.scss case merges
  align-items/display: flex directly into the existing .mzp-c-menu-title
  rule, replacing its display: block fallback outright rather than
  keeping a separate feature-query block for a feature every supported
  browser has.
- Removed the base/elements/_reset.scss block resetting article, aside,
  details, figcaption, figure, footer, header, hgroup, main, nav,
  section, and summary to display: block -- every one of these has had
  correct default display in every supported browser for over a decade.
  Left the audio/video/canvas -> inline-block reset alone: that's a
  deliberate style choice (those are inline-level by spec in every
  browser), not a legacy-browser shim, so it doesn't belong to this
  cleanup.
- Removed the &::-ms-expand selector in the Select form reset (pure
  legacy IE/Edge, matches nothing in any supported browser).
- Replaced -webkit-appearance with the standard unprefixed appearance
  property in the two remaining form resets (search decoration, file
  upload button) and removed their now-unnecessary stylelint-disable
  comments. Re-enabled property-no-vendor-prefix and
  value-no-vendor-prefix in .stylelintrc.json as the ongoing enforcement
  lever -- confirmed empirically these two were the only real hits;
  the rules don't flag vendor-prefixed pseudo-elements
  (::-moz-focus-inner, ::-webkit-details-marker) or non-standard,
  prefix-only properties (-moz-osx-font-smoothing,
  -webkit-font-smoothing) that have no unprefixed equivalent, so the
  other 6 remaining prefixes in the codebase are correctly left alone.
- appearance: button was flagged separately as a deprecated keyword
  for the unprefixed property (declaration-property-value-keyword-no-deprecated);
  changed to appearance: auto, which is the correct modern equivalent
  (native appearance for that pseudo-element is already button-shaped).
- Removed stale "in IE"/"in Edge and IE" references from three
  comment blocks in _forms.scss. Left the normalize.css resets those
  comments document in place -- e.g. the textarea scrollbar and legend
  box-sizing resets -- since I can't confirm from source alone that
  every supported browser makes them fully redundant, and that's a
  bigger, separate call from removing definitively dead code like the
  @supports/-ms-/reset.scss cases above.

Stacked on #1135 (v23/support-config). Part of #1084.

Verified: npm run lint, npm test (47 specs, Firefox + Chrome), and a
direct sass --verbose compile confirming the merged menu-title rule,
the unwrapped sticky-nav rule, and the removed -ms-/@supports code in
the compiled CSS.
…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 added this pull request to stack #1146 September 11, 2026 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant