Skip to content

Instantly share code, notes, and snippets.

@piyawath
Forked from paulirish/gist:5558557
Created November 11, 2019 06:11
Show Gist options
  • Select an option

  • Save piyawath/0323088d80a0c4beda977455b1ec0a43 to your computer and use it in GitHub Desktop.

Select an option

Save piyawath/0323088d80a0c4beda977455b1ec0a43 to your computer and use it in GitHub Desktop.

Revisions

  1. @paulirish paulirish revised this gist May 13, 2013. 1 changed file with 9 additions and 9 deletions.
    18 changes: 9 additions & 9 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,11 @@
    A timeline of the last four years of detecting good old `window.localStorage`
    A timeline of the last four years of detecting good old `window.localStorage`.

    <hr>

    #### Jan Lenhart, bless his heart contributed the first patch for support:

    October 2009:
    https://github.com/Modernizr/Modernizr/commit/5059daa4674651cd1adc39d902e4f4afa73426cd#L0R413
    [5059daa](https://github.com/Modernizr/Modernizr/commit/5059daa4674651cd1adc39d902e4f4afa73426cd#L0R413)

    ```js
    (typeof window.localStorage != 'undefined')
    @@ -14,7 +14,7 @@ https://github.com/Modernizr/Modernizr/commit/5059daa4674651cd1adc39d902e4f4afa7
    #### Simplicifations

    November 2009:
    https://github.com/Modernizr/Modernizr/commit/15020e75cb21d29e3514570704aabfa2a9c4ca84#L0L419
    [15020e7](https://github.com/Modernizr/Modernizr/commit/15020e75cb21d29e3514570704aabfa2a9c4ca84#L0L419)

    ```js
    !!window.localStorage
    @@ -23,7 +23,7 @@ https://github.com/Modernizr/Modernizr/commit/15020e75cb21d29e3514570704aabfa2a9
    #### If cookies disabled in FF, exception. Softer detect

    December 2009:
    https://github.com/Modernizr/Modernizr/commit/1e0ba919fa1e71172334df3fb37f5c3a07dacc49?w=1#L0R455
    [1e0ba91](https://github.com/Modernizr/Modernizr/commit/1e0ba919fa1e71172334df3fb37f5c3a07dacc49?w=1#L0R455)

    ```js
    !!('localStorage' in window)
    @@ -32,7 +32,7 @@ https://github.com/Modernizr/Modernizr/commit/1e0ba919fa1e71172334df3fb37f5c3a07
    #### If DOM storage disabled in IE, `window.localStorage` is _present_ but `=== null`.

    January 2010:
    https://github.com/Modernizr/Modernizr/commit/d8947c91982b8018e1d119be44d9c3ed85e521b6#L0L580
    [d8947c9](https://github.com/Modernizr/Modernizr/commit/d8947c91982b8018e1d119be44d9c3ed85e521b6#L0L580)

    ```js
    (localStorage in window) && window[localStorage] !== null
    @@ -41,7 +41,7 @@ https://github.com/Modernizr/Modernizr/commit/d8947c91982b8018e1d119be44d9c3ed85
    #### FF with dom.storage.enabled = false throws exceptions

    July 2010:
    https://github.com/Modernizr/Modernizr/commit/ef2c47#L0R633
    [ef2c47](https://github.com/Modernizr/Modernizr/commit/ef2c47#L0R633)

    ```js
    try {
    @@ -54,7 +54,7 @@ try {
    #### more shit because of FF exceptions

    December 2010:
    https://github.com/Modernizr/Modernizr/commit/c630c3938f704bfb4153bc939dc2eeee012e34b5?w=1
    [c630c39](https://github.com/Modernizr/Modernizr/commit/c630c3938f704bfb4153bc939dc2eeee012e34b5?w=1)

    ```js
    try {
    @@ -68,7 +68,7 @@ try {
    #### iOS private browsing fucks everyone!!!

    October 2011:
    https://github.com/Modernizr/Modernizr/commit/5e2fa0ed336279990b8070726c596d7aa2c00b00
    [5e2fa0e](https://github.com/Modernizr/Modernizr/commit/5e2fa0ed336279990b8070726c596d7aa2c00b00)

    ```js
    try {
    @@ -82,7 +82,7 @@ try {
    #### stronger full capability test for localstorage with iOS private browsing protection

    October 2011:
    https://github.com/Modernizr/Modernizr/commit/a93625c21694fcda6fc1514a48f54232f703194a
    [a93625c](https://github.com/Modernizr/Modernizr/commit/a93625c21694fcda6fc1514a48f54232f703194a)

    ```js
    try {
  2. @paulirish paulirish revised this gist May 13, 2013. 1 changed file with 51 additions and 31 deletions.
    82 changes: 51 additions & 31 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -4,72 +4,92 @@ A timeline of the last four years of detecting good old `window.localStorage`

    #### Jan Lenhart, bless his heart contributed the first patch for support:

    October 2009:
    https://github.com/Modernizr/Modernizr/commit/5059daa4674651cd1adc39d902e4f4afa73426cd#L0R413

    (typeof window.localStorage != 'undefined')

    ```js
    (typeof window.localStorage != 'undefined')
    ```

    #### Simplicifations

    November 2009:
    https://github.com/Modernizr/Modernizr/commit/15020e75cb21d29e3514570704aabfa2a9c4ca84#L0L419

    !!window.localStorage

    ```js
    !!window.localStorage
    ```

    #### If cookies disabled in FF, exception. Softer detect

    December 2009:
    https://github.com/Modernizr/Modernizr/commit/1e0ba919fa1e71172334df3fb37f5c3a07dacc49?w=1#L0R455

    !!('localStorage' in window)
    ```js
    !!('localStorage' in window)
    ```

    #### If DOM storage disabled in IE, `window.localStorage` is _present_ but `=== null`.

    January 2010:
    https://github.com/Modernizr/Modernizr/commit/d8947c91982b8018e1d119be44d9c3ed85e521b6#L0L580

    (localStorage in window) && window[localStorage] !== null
    ```js
    (localStorage in window) && window[localStorage] !== null
    ```

    #### FF with dom.storage.enabled = false throws exceptions
    https://github.com/Modernizr/Modernizr/commit/ef2c47#L0R633

    try {
    return ('localStorage' in window) && window[localstorage] !== null;
    } catch(e) {
    return false;
    }
    July 2010:
    https://github.com/Modernizr/Modernizr/commit/ef2c47#L0R633

    ```js
    try {
    return ('localStorage' in window) && window[localstorage] !== null;
    } catch(e) {
    return false;
    }
    ```

    #### more shit because of FF exceptions

    December 2010:
    https://github.com/Modernizr/Modernizr/commit/c630c3938f704bfb4153bc939dc2eeee012e34b5?w=1

    try {
    return !!localStorage.getItem;
    } catch(e) {
    return false;
    }
    ```js
    try {
    return !!localStorage.getItem;
    } catch(e) {
    return false;
    }
    ```


    #### iOS private browsing fucks everyone!!!

    October 2011:
    https://github.com/Modernizr/Modernizr/commit/5e2fa0ed336279990b8070726c596d7aa2c00b00

    try {
    return !!localStorage.getItem('getItem');
    } catch(e) {
    return false;
    }

    ```js
    try {
    return !!localStorage.getItem('getItem');
    } catch(e) {
    return false;
    }
    ```


    #### stronger full capability test for localstorage with iOS private browsing protection

    October 2011:
    https://github.com/Modernizr/Modernizr/commit/a93625c21694fcda6fc1514a48f54232f703194a

    try {
    localStorage.setItem(mod, mod);
    localStorage.removeItem(mod);
    return true;
    } catch(e) {
    return false;
    }
    ```js
    try {
    localStorage.setItem(mod, mod);
    localStorage.removeItem(mod);
    return true;
    } catch(e) {
    return false;
    }
    ```
  3. @paulirish paulirish revised this gist May 11, 2013. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,7 @@
    A timeline of the last four years of detecting good old `window.localStorage`

    <hr>

    #### Jan Lenhart, bless his heart contributed the first patch for support:

    https://github.com/Modernizr/Modernizr/commit/5059daa4674651cd1adc39d902e4f4afa73426cd#L0R413
  4. @paulirish paulirish renamed this gist May 11, 2013. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion gistfile1.txt → gistfile1.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,3 @@

    #### Jan Lenhart, bless his heart contributed the first patch for support:

    https://github.com/Modernizr/Modernizr/commit/5059daa4674651cd1adc39d902e4f4afa73426cd#L0R413
  5. @paulirish paulirish created this gist May 11, 2013.
    72 changes: 72 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,72 @@

    #### Jan Lenhart, bless his heart contributed the first patch for support:

    https://github.com/Modernizr/Modernizr/commit/5059daa4674651cd1adc39d902e4f4afa73426cd#L0R413

    (typeof window.localStorage != 'undefined')


    #### Simplicifations

    https://github.com/Modernizr/Modernizr/commit/15020e75cb21d29e3514570704aabfa2a9c4ca84#L0L419

    !!window.localStorage


    #### If cookies disabled in FF, exception. Softer detect

    https://github.com/Modernizr/Modernizr/commit/1e0ba919fa1e71172334df3fb37f5c3a07dacc49?w=1#L0R455

    !!('localStorage' in window)

    #### If DOM storage disabled in IE, `window.localStorage` is _present_ but `=== null`.

    https://github.com/Modernizr/Modernizr/commit/d8947c91982b8018e1d119be44d9c3ed85e521b6#L0L580

    (localStorage in window) && window[localStorage] !== null

    #### FF with dom.storage.enabled = false throws exceptions
    https://github.com/Modernizr/Modernizr/commit/ef2c47#L0R633

    try {
    return ('localStorage' in window) && window[localstorage] !== null;
    } catch(e) {
    return false;
    }



    #### more shit because of FF exceptions

    https://github.com/Modernizr/Modernizr/commit/c630c3938f704bfb4153bc939dc2eeee012e34b5?w=1

    try {
    return !!localStorage.getItem;
    } catch(e) {
    return false;
    }


    #### iOS private browsing fucks everyone!!!

    https://github.com/Modernizr/Modernizr/commit/5e2fa0ed336279990b8070726c596d7aa2c00b00

    try {
    return !!localStorage.getItem('getItem');
    } catch(e) {
    return false;
    }



    #### stronger full capability test for localstorage with iOS private browsing protection

    https://github.com/Modernizr/Modernizr/commit/a93625c21694fcda6fc1514a48f54232f703194a

    try {
    localStorage.setItem(mod, mod);
    localStorage.removeItem(mod);
    return true;
    } catch(e) {
    return false;
    }