2

I'm having issues with the monostate pattern in Firefox 35, using Polymer 0.5.2. My element looks like this:

<polymer-element name="tracer-globals">
  <script>
    (function() {

      var store = document.createElement('tracer-store');

      Polymer({
        publish: {
          store: null
        },

        ready: function() {
          this.store = store;
        }
      });
    })();
  </script>
</polymer-element>

In Chrome at the point of ready I can see the various attributes of the store object, but on Firefox, the attributes are never defined (even long after the app has finished loading).

Any ideas why?

Things I've tried:

  • Ensure tracer-store is imported before tracer-globals.
user3452758
  • 638
  • 1
  • 7
  • 15

1 Answers1

1

Found a workaround:

Lazy-load the global object in the created callback:

<polymer-element name="tracer-globals">
  <script>
    (function() {

      var store = null;

      var getStore = function() {
        if (store === null) {
          store = document.createElement('tracer-store');
        }
        return store;
      };

      Polymer({
        publish: {
          store: null
        },

        created: function() {
          this.store = getStore();
        }
      });
    })();
  </script>
</polymer-element>

Would appreciate comments as to why this works.

user3452758
  • 638
  • 1
  • 7
  • 15