Au 2.0: Do we not have defaultBindingMode on @customElement?

Hello,

On my Devextreme wrappers, I have this ad infinitum:

...
@bindable({ mode: BindingMode.twoWay }) accessKey = undefined;
@bindable({ mode: BindingMode.twoWay }) activeStateEnabled = true;
@bindable({ mode: BindingMode.twoWay }) buttons = undefined;
@bindable({ mode: BindingMode.twoWay }) disabled = false;
@bindable({ mode: BindingMode.twoWay }) elementAttr = {};
@bindable({ mode: BindingMode.twoWay }) focusStateEnabled = true;
@bindable({ mode: BindingMode.twoWay }) height = undefined;
@bindable({ mode: BindingMode.twoWay }) hint = undefined;
@bindable({ mode: BindingMode.twoWay }) hoverStateEnabled = true;
@bindable({ mode: BindingMode.twoWay }) inputAttr = {};
@bindable({ mode: BindingMode.twoWay }) isDirty = false;
...

I see defaultBindingMode for custom attributes, but not for custom elements. I would like to be able to do this:

@customElement({
  name: 'tsi-dx-text-box',
  template: null,
  processContent(node, _, instructionData) {
    return harvestDxTemplates(node, _, instructionData);
  },
  defaultBindingMode: BindingMode.twoWay
})

Am I missing it somewhere?

@estaylorco no you are not missing it. Having a default binding mode on element was deemed not enough sense since there’s no really default bindable properties, unlike attribute, where you always at least have value.

From your example, it kind of makes sense that custom element can have a default mode config too, maybe let’s create a feature request on Github?

Done: Add defaultBindingMode to @customElement/CustomElementDefinition (in symmetry with custom attributes) · Issue #2328 · aurelia/aurelia · GitHub .

1 Like