Uploaded image for project: 'Alloy'
  1. Alloy
  2. ALOY-1369

Complex data binding for collection doesn't work with transform

    Details

    • Type: Bug
    • Status: Closed
    • Priority: None
    • Resolution: Fixed
    • Affects Version/s: alloy 1.7.35
    • Fix Version/s: alloy 1.8.1, Release 5.2.2
    • Component/s: Models, XML
    • Labels:
      None
    • Environment:

      Alloy 1.7.35

      Description

      The complex data binding introduced by ALOY-443 does not work if the model has a __transform property:

      <Alloy>
      	<Collection src="user" />
      	<Window>
      		<TableView dataCollection="user">
      			<TableViewRow foo="{a}" bar="the {a}" title="{a} {b}" />
      		</TableView>
      	</Window>
      </Alloy>
      

      Compiles to:

          __alloyId3.__transform = {};
          var __alloyId5 = Ti.UI.createTableViewRow({
            foo: typeof __alloyId3.__transform['a'] !== 'undefined' ? __alloyId3.__transform['a'] : __alloyId3.get('a'),
            bar: typeof __alloyId3.__transform['a'] !== 'undefined' ? __alloyId3.__transform['a'] : the '+__alloyId3.get('
            a ') +',
            title: typeof __alloyId3.__transform['a'] !== 'undefined' ? __alloyId3.__transform['a'] : __alloyId3.get('a') + ' ' + __alloyId3.get('b'),
          });
      

      Which will cause Uglify to crash on the syntax error on line 3.

      For the other 2 cases the values will always that of a if the model has a __transform property.

      The correct code should be:

          __alloyId3.__transform = _.isFunction(__alloyId3.transform) ? __alloyId3.transform() : __alloyId3.toJSON();
          var __alloyId5 = Ti.UI.createTableViewRow({
            foo: _.template("<%=a%>", __alloyId3.__transform),
            bar: _.template("<%=the a%>", __alloyId3.__transform),
            title: _.template("<%=a b%>", __alloyId3.__transform)
          });
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                fokkezb Fokke Zandbergen
                Reporter:
                fokkezb Fokke Zandbergen
                Reviewer:
                Feon Sua Xin Miao
              • Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                    Git Integration