MCPcopy Create free account
hub / github.com/ampproject/amphtml / getMajorVersion

Function getMajorVersion

src/preact/utils/platform.js:111–130  ·  view source on GitHub ↗

* Returns the major version of the browser. * @return {number}

()

Source from the content-addressed store, hash-verified

109 * @return {number}
110 */
111 getMajorVersion() {
112 if (this.isSafari()) {
113 return this.isIos()
114 ? this.getIosMajorVersion() || 0
115 : this.evalMajorVersion_(/\sVersion\/(\d+)/, 1);
116 }
117 if (this.isChrome()) {
118 return this.evalMajorVersion_(/(Chrome|CriOS)\/(\d+)/, 2);
119 }
120 if (this.isFirefox()) {
121 return this.evalMajorVersion_(/(Firefox|FxiOS)\/(\d+)/, 2);
122 }
123 if (this.isOpera()) {
124 return this.evalMajorVersion_(/(OPR|Opera|OPiOS)\/(\d+)/, 2);
125 }
126 if (this.isEdge()) {
127 return this.evalMajorVersion_(/Edge\/(\d+)/, 1);
128 }
129 return 0;
130 },
131
132 /**
133 * @param {!RegExp} expr

Callers

nothing calls this directly

Calls 8

isSafariMethod · 0.80
isIosMethod · 0.80
getIosMajorVersionMethod · 0.80
evalMajorVersion_Method · 0.80
isChromeMethod · 0.80
isFirefoxMethod · 0.80
isOperaMethod · 0.80
isEdgeMethod · 0.80

Tested by

no test coverage detected