Skip to content

Update platform detection logic#9744

Open
pmario wants to merge 1 commit intoTiddlyWiki:masterfrom
pmario:update-navigator-platform-check-7621
Open

Update platform detection logic#9744
pmario wants to merge 1 commit intoTiddlyWiki:masterfrom
pmario:update-navigator-platform-check-7621

Conversation

@pmario
Copy link
Copy Markdown
Member

@pmario pmario commented Mar 16, 2026

Summary

  • Replace deprecated navigator.platform with modern navigator.userAgentData.platform API for browser platform detection
  • Fall back to navigator.platform for browsers that don't yet support userAgentData (Firefox, Safari)
  • Make all platform regex checks case-insensitive to handle both APIs (userAgentData returns "macOS" vs navigator.platform returning "MacIntel")

Test plan

  • Node.js tests pass (1445 specs, 0 failures)
  • Verify $tw.platform values are correct in Chrome/Edge (uses userAgentData path)
  • Verify $tw.platform values are correct in Firefox/Safari (uses navigator.platform fallback)
  • Verify keyboard shortcuts use correct modifier key (Cmd on Mac, Ctrl on Windows/Linux)
  • Check $:/info/browser/is-mac, is-windows, is-linux tiddlers are set correctly

Details

navigator.platform is deprecated and browsers may eventually remove it. This change uses feature detection to prefer navigator.userAgentData.platform when available, with a graceful fallback to the deprecated API for older browsers.

Only the TiddlyWiki-owned code in core/modules/startup/startup.js is changed. Vendored third-party libraries (CodeMirror, Leaflet) that also use navigator.platform are left as-is.

Fixes #7621

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 16, 2026

Deploy Preview for tiddlywiki-previews ready!

Name Link
🔨 Latest commit 1b2cb53
🔍 Latest deploy log https://app.netlify.com/projects/tiddlywiki-previews/deploys/69b7f95224746300080cbc78
😎 Deploy Preview https://deploy-preview-9744--tiddlywiki-previews.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions
Copy link
Copy Markdown

Confirmed: pmario has already signed the Contributor License Agreement (see contributing.md)

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 16, 2026

📊 Build Size Comparison: empty.html

Branch Size
Base (master) 2487.2 KB
PR 2487.3 KB

Diff: ⬆️ Increase: +0.1 KB


⚠️ Change Note Status

This PR appears to contain code changes but doesn't include a change note.

Please add a change note by creating a .tid file in editions/tw5.com/tiddlers/releasenotes/<version>/

📚 Documentation: Release Notes and Changes

💡 Note: If this is a documentation-only change, you can ignore this message.

@pmario
Copy link
Copy Markdown
Member Author

pmario commented Mar 16, 2026

I did test all the checks with FireFox and Edge

@Jermolene ... can you test on Mac

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.

Deprecated info: navigator.platform is deprecated

1 participant