From 95e0fac6556a9bfe4e8b4e7d44d6487f7e67b12b Mon Sep 17 00:00:00 2001 From: lin onetwo Date: Sat, 14 May 2022 21:02:52 +0800 Subject: [PATCH] Expose isMobile to browser info (#6675) * feat: expose isMobile to info * feat: allow access browser info from $tw.browser * fix: adapt typo * refactor: only export selected properties Jermolene 5 hours ago The trouble is that the properties of bowser.browser are not under our direct control, and so subsequent updates to Bowser might overwrite important properties of our own. I'd rather explicitly import the properties that we choose to support. * refactor: put things into `is` --- plugins/tiddlywiki/browser-sniff/browser.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/tiddlywiki/browser-sniff/browser.js b/plugins/tiddlywiki/browser-sniff/browser.js index 2ca0b4840..26989623a 100644 --- a/plugins/tiddlywiki/browser-sniff/browser.js +++ b/plugins/tiddlywiki/browser-sniff/browser.js @@ -42,8 +42,12 @@ exports.getInfoTiddlerFields = function() { ["is/sailfish","sailfish"], ["is/android","android"], ["is/windowsphone","windowsphone"], - ["is/firefoxos","firefoxos"] + ["is/firefoxos","firefoxos"], + ["is/mobile","mobile"] ]; + $tw.browser = $tw.utils.extend($tw.browser, { + is: bowser.browser, + }); $tw.utils.each(mappings,function(mapping) { var value = bowser.browser[mapping[1]]; if(value === undefined) {