Note that there are some explanatory texts on larger screens.

plurals
  1. POStrange Closure Compiler issue
    primarykey
    data
    text
    <p>I'm using Google's Closure Compiler in advanced mode, and I'm having a strange issue. Here is the uncompiled code, with returned log statement from the compiled version running:</p> <pre><code>goog.provide('frame.store'); goog.require('frame.storeBack.LocalStore'); goog.require('frame.storeBack.Mem'); frame.store = (function() { /** prioritised list of backends **/ var backends = [ frame.storeBack.LocalStore, frame.storeBack.Mem ]; frame.log(backends); // [function rc(){}, function tc(){this.q={}}] frame.log(frame.storeBack.LocalStore === backends[0]); // true frame.log(frame.storeBack.LocalStore.isAvailable === backends[0].isAvailable); // false frame.log(frame.storeBack.LocalStore.isAvailable); // function sc(){try{return"localStorage"in window&amp;&amp;window.localStorage!==k}catch(a){return l}} frame.log(backends[0].isAvailable); // undefined for (var i=0, len=backends.length; i&lt;len; i++) if (backends[i].isAvailable()) return new backends[i](); // Uncaught TypeError: Object function rc(){} has no method 'Ga' throw('no suitable storage backend'); })(); </code></pre> <p>For some reason the static method isAvailable is not present when LocalStore is accessed via the backends array, and is present when it's accessed via it's global namespace.</p> <p>Can anyone see why?</p> <p>EDIT: for reference, here is the method declaration:</p> <pre><code>frame.storeBack.LocalStore.isAvailable = function() { try { return 'localStorage' in window &amp;&amp; window['localStorage'] !== null; }catch (e) { return false; } }; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload