Polymer / tools

Polymer Tools Monorepo
BSD 3-Clause "New" or "Revised" License
430 stars 200 forks source link

Modulizer moved behavior definition to after usage #2797

Open e111077 opened 6 years ago

e111077 commented 6 years ago

Modulizer transformed Polymer/polymer/test/unit/property-effects-elements.html from: link (github is going all syntax crazy here)

(function(){
  var TranslateBehavior = { // definition
    properties: {
      translateMessage: {
        type: Function,
        computed: '_computeTranslateFn(translator)'
      }
    }
  };
  Polymer({
    is: 'x-bind-computed-property',
    behaviors: [TranslateBehavior], // usage
    properties: {
      translator: {
        type: Function,
        value: function() {
          return function(message) {
            return 'translated: ' + message;
          };
        }
      }
    },
    _computeTranslateFn: function(translator) {
      return function(message) {
        return translator(message);
      };
    }
  });
})();

to: link

Polymer({
  _template: html`
    <div id="check">[[translateMessage('Hello World.')]]</div>
`,
  is: 'x-bind-computed-property',
  behaviors: [TranslateBehavior], // usage
  properties: {
    translator: {
      type: Function,
      value: function() {
        return function(message) {
          return 'translated: ' + message;
        };
      }
    }
  },
  _computeTranslateFn: function(translator) {
    return function(message) {
      return translator(message);
    };
  }
});
var TranslateBehavior = { // definition
  properties: {
    translateMessage: {
      type: Function,
      computed: '_computeTranslateFn(translator)'
    }
  }
};

This may be related to #405.

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.