Repository: browserslist/browserslist (language: javascript)

Issue:
Unreleased versions will be included when querying `since 1970`
When querying `since 1970`, it will be parsed into the UNIX timestamp `0`. On the other hand, in `caniuse-lite` data, release date of unreleased versions are `null`.

Now, when processing `since` query, there is a comparison logic: https://github.com/browserslist/browserslist/blob/29cecf978e78d4e3daab99809e8816488fcf8fb7/index.js#L212 .

In JavaScript, `null >= 0` will be evaluated to `true`, which causes unreleased versions will be included in the result when querying `since 1970`.

I'm not sure whether it's a bug or not. I found this problem when I was implementing `since` query in [browserslist-rs](https://github.com/g-plane/browserslist-rs), and currently I implemented this feature/bug as-is: https://github.com/g-plane/browserslist-rs/blob/35ed72f516ab1230d0c102169a9bbe25f493fedb/src/queries/since.rs#L53-L62 .


Discussion / hints:
Wow, crazy bug. Thanks.

I will add special logic for `null`. We should not use `data.releaseDate[v] === null` in any `since X` query.

Fix patch:
diff --git a/index.js b/index.js
index 0ed423e7..7b752e47 100644
--- a/index.js
+++ b/index.js
@@ -209,7 +209,8 @@ function filterByYear(since, context) {
     var data = byName(name, context)
     if (!data) return selected
     var versions = Object.keys(data.releaseDate).filter(function (v) {
-      return data.releaseDate[v] >= since
+      var date = data.releaseDate[v]
+      return date !== null && date >= since
     })
     return selected.concat(versions.map(nameMapper(data.name)))
   }, [])


Test patch:
diff --git a/test/since.test.js b/test/since.test.js
index a900e1dc..22263fe2 100644
--- a/test/since.test.js
+++ b/test/since.test.js
@@ -14,6 +14,15 @@ beforeEach(() => {
         2: 1483228800, // Sun, 01 Jan 2017 00:00:00 +0000
         3: 1485907200 // Wed, 01 Feb 2017 00:00:00 +0000
       }
+    },
+    safari: {
+      name: 'safari',
+      versions: ['TP'],
+      released: [],
+      releaseDate: {
+        1: 1451606400, // Fri, 01 Jan 2016 00:00:00 +0000
+        TP: null // unreleased
+      }
     }
   }
   console.warn = function (...args) {
@@ -28,11 +37,11 @@ afterEach(() => {
 })
 
 it('selects versions released on year boundaries', () => {
-  expect(browserslist('since 1970')).toEqual(['ie 3', 'ie 2', 'ie 1'])
+  expect(browserslist('since 1970')).toEqual(['ie 3', 'ie 2', 'ie 1', 'safari 1'])
 })
 
 it('is case insensitive', () => {
-  expect(browserslist('Since 1970')).toEqual(['ie 3', 'ie 2', 'ie 1'])
+  expect(browserslist('Since 1970')).toEqual(['ie 3', 'ie 2', 'ie 1', 'safari 1'])
 })
 
 it('selects versions released on year and month boundaries', () => {