foam-framework/foam

U2: view attribute not handling property value bindings correctly

mdittmer opened this issue · 2 comments

Neither toE1 nor toE2 work correctly; they also have different console output.

CLASS({
  package: 'foam',
  name: 'TestData',

  requires: [
    'foam.util.Timer',
  ],

  models: [
    {
      name: 'TestView',
      extends: 'foam.u2.DetailView',

      properties: [
        {
          name: 'bar',
          defaultValue: 'bar',
          attribute: true,
          postSet: function() {
            console.log('View attribute, bar, change', this.bar);
          },
        },
      ],

      methods: [
        function initE() {
          this.add(this.bar$);
        },
      ],
    },
  ],

  properties: [
    {
      name: 'timer',
      factory: function() {
        var timer = this.Timer.create();
        timer.start();
        timer.second$.addListener(function() {
          console.log('Timer second change', timer.second);
        });
        return timer;
      },
    },
    {
      name: 'foo',
      toPropertyE: function(X) {
        return X.lookup('foam.TestData.TestView').create({ data: this.foo }, X);
      },
    },
  ],

  methods: [
    function init() {
      this.X.data = this;
    },
  ],

  templates: [
    function toE1() {/*#U2
      <div><:foo bar={{this.timer.second$}} /></div>
    */},
    function toE2() {/*#U2
      <div><:foo bar={{this.X.dynamic(function(s) {
        console.log('Dynamic for view property, bar, change', s);
        return s.toString();
      }, this.timer.second$)}} /></div>
    */},
  ],
});

toE1 renders nothing. This appears to be an incorrect falseyness check when it is set to integer 0. toE2, based on logging, is working correctly, but what's rendered in the DOM doesn't change from "0".

It appears to be working fine for me. If I rename either toE1() or toE2() to just toE(), and then load it with:

http://localhost:8000/index.html?model=foam.TestData

I see an incrementing number.

Not an issue. My local repo was out of date.