Przeglądaj źródła

fix: Fixes version comparison. (#693)

* fix: Fixes version comparison.

* fix(BrowserCapabilities): Searching for the correct version from capabilitiesDB.

* fix(BrowserDetection): Remove unnecessary checks.
dev1
bgrozev 8 lat temu
rodzic
commit
e895c9b86f

+ 1
- 1
modules/browser/BrowserCapabilities.js Wyświetl plik

@@ -25,7 +25,7 @@ export default class BrowserCapabilities extends BrowserDetection {
25 25
 
26 26
         const browserCapabilities = capabilitiesDB[this.getName()] || [];
27 27
         const capabilitiesByVersion = browserCapabilities.find(({ version }) =>
28
-            !version || !this.isVersionLessThan(version));
28
+            !version || !this.isVersionGreaterThan(version));
29 29
 
30 30
         if (!capabilitiesByVersion || !capabilitiesByVersion.capabilities) {
31 31
             this._capabilities = { isSupported: false };

+ 3
- 9
modules/browser/BrowserDetection.js Wyświetl plik

@@ -272,9 +272,7 @@ export default class BrowserDetection {
272 272
      * greater than the passed version and false otherwise.
273 273
      */
274 274
     isVersionGreaterThan(version) {
275
-        if (this._version) {
276
-            return this.compareVersion(version) === 1;
277
-        }
275
+        return this.compareVersion(version) === -1;
278 276
     }
279 277
 
280 278
     /**
@@ -285,9 +283,7 @@ export default class BrowserDetection {
285 283
      * lower than the passed version and false otherwise.
286 284
      */
287 285
     isVersionLessThan(version) {
288
-        if (this._version) {
289
-            return this.compareVersion(version) === -1;
290
-        }
286
+        return this.compareVersion(version) === 1;
291 287
     }
292 288
 
293 289
     /**
@@ -298,8 +294,6 @@ export default class BrowserDetection {
298 294
      * equal to the passed version and false otherwise.
299 295
      */
300 296
     isVersionEqualTo(version) {
301
-        if (this._version) {
302
-            return this.compareVersion(version) === 0;
303
-        }
297
+        return this.compareVersion(version) === 0;
304 298
     }
305 299
 }

Ładowanie…
Anuluj
Zapisz