Tagify with NULL data source throwing error in console with AC2

Wappler Version : 6.8.0
Operating System : W11
Server Model: NodeJS

Code:

ddPlan.data.accomp_year.default(scInfo.data.plan.accomp_year)

Here accomp_year is a simple array like [2021,2022,2023] etc.
This setup was working on with AC1. But with AC2, below error is thrown in console when both ddPlan and scInfo return NULL.

image

I tried adding another default to handle this, but it didn't work:

ddPlan.data.accomp_year.default(scInfo.data.plan.accomp_year.default([]))

If I bind the data source directly to empty array [] it does not throw any error.

Bump.

Seeing the stacktrace it is not the data that is null. The _whitelist function has an array check and the code comes into the Array.map. The error is generated on one of the items inside the data array, one of those items is a null value.

Isn't whitelist the default list?
Probably the binding is resolving as undefined or something that is not NULL?
Because I can assure you, there is no data here.. no item inside that can be null either.

You can wrap the expression in a log() for debugging like log(ddPlan.data.accomp_year.default(scInfo.data.plan.accomp_year)). It will still pass the value to the component but also outputs it in the console.

The stacktrace shows that it executes the _whitelist function and then the Array.map. The actual error is when reading the style property from a data item. Seeing that it executes the Array.map it means that the data must have been an array and that one of the items is a null value.

The source code for the _whitelist function:

  _whitelist () { // this.props.data is the data passed
    return Array.isArray(this.props.data) ? this.props.data.map(item => {
      const scope = dmx.DataScope(item, this);
      const tagData = {
        __dmx: true,
        __item: item,
        value: String(dmx.parse(this.props.tagValue, scope)),
        label: String(dmx.parse(this.props.tagText, scope)),
      };

      // The error is generated on the next line
      if (item.style) tagData.style = item.style; // <<<< ERROR
      if (this.props.tagSecondary) tagData.secondary = dmx.parse(this.props.tagSecondary, scope);
      if (this.props.tagImage) tagData.image = dmx.parse(this.props.tagImage, scope);
      if (this.props.tagClass) tagData.class = dmx.parse(this.props.tagClass, scope);
      if (this.props.tagCount) tagData.count = dmx.parse(this.props.tagCount, scope);
      if (this.props.tagReadonly) tagData.readonly = !!dmx.parse(this.props.tagReadonly, scope);

      return tagData;
    }) : [];
  },

image

Getting undefined.

And exactly the same error with same stacktrace when data is undefined?

With the log function, seeing only undefined, no other error.

Without the log function, getting a slightly different error message now. Not sure why.

Have no idea what goes wrong but have added an extra check in the _whitelist function, when there is an item undefined/null it should show a warning in the console and not trigger an error.

dmxTagify.zip (9.8 KB)

In the last stacktrace I see getWhitelist being called, this is a Function of the AC1 component and not AC2.

Ah. Must be some issue on the dev's machine. Will test the new version and get back to you asap.