-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace css_browser_selector with our own implementation (#2854)
* Replace css_browser_selector * Add classes to root element instead of body * Export addBrowserClasses() in reviewer_extras for mobile clients (dae) * Avoid setting .mac on iOS devices (dae)
- Loading branch information
Showing
11 changed files
with
51 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,13 +166,6 @@ | |
"path": "node_modules/commander", | ||
"licenseFile": "node_modules/commander/LICENSE" | ||
}, | ||
"[email protected]": { | ||
"licenses": "CC-BY-SA-2.5", | ||
"repository": "https://github.com/verbatim/css_browser_selector", | ||
"publisher": "Rafael Lima", | ||
"path": "node_modules/css-browser-selector", | ||
"licenseFile": "node_modules/css-browser-selector/README.mkdn" | ||
}, | ||
"[email protected]": { | ||
"licenses": "MIT", | ||
"repository": "https://github.com/NV/CSSOM", | ||
|
@@ -840,4 +833,3 @@ | |
"licenseFile": "node_modules/xmlchars/LICENSE" | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright: Ankitects Pty Ltd and contributors | ||
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html | ||
|
||
export function addBrowserClasses() { | ||
const ua = navigator.userAgent.toLowerCase(); | ||
|
||
function addClass(className: string) { | ||
document.documentElement.classList.add(className); | ||
} | ||
|
||
function test(regex: RegExp): boolean { | ||
return regex.test(ua); | ||
} | ||
|
||
if (test(/ipad/)) { | ||
addClass("ipad"); | ||
} else if (test(/iphone/)) { | ||
addClass("iphone"); | ||
} else if (test(/android/)) { | ||
addClass("android"); | ||
} | ||
|
||
if (test(/ipad|iphone|ipod/)) { | ||
addClass("ios"); | ||
} | ||
|
||
if (test(/ipad|iphone|ipod|android/)) { | ||
addClass("mobile"); | ||
} else if (test(/linux/)) { | ||
addClass("linux"); | ||
} else if (test(/windows/)) { | ||
addClass("win"); | ||
} else if (test(/mac/)) { | ||
addClass("mac"); | ||
} | ||
|
||
if (test(/firefox\//)) { | ||
addClass("firefox"); | ||
} else if (test(/chrome\//)) { | ||
addClass("chrome"); | ||
} else if (test(/safari\//)) { | ||
addClass("safari"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters