Skip to content

ethicalads.wait does not correctly handle cases with no available ads #217

@logocomune

Description

@logocomune

I am encountering an issue with the behavior of ethicalads.wait. I expect that when no ads are available, the code should execute the branch displaying the alternative content (console.debug('Loading backup content');). However, in all cases, the code always executes the else branch, even when placements is an empty array.

Steps to Reproduce the Issue

  1. Add the following code to the application:
    ethicalads.load();
    ethicalads.wait.then((placements:any) => {
        if (!placements.length) {
            console.debug('Loading backup content');
            showAlternative = true;
        } else {
            console.debug('EthicalAds are loaded');
        }
    });
  2. Check the behavior when no ads are available.

Expected Behavior

When no ads are available (placements is an empty array), I expect the if branch to execute, including console.debug('Loading backup content');.

Actual Behavior

Even when no ads are available, the code always executes the else branch and logs console.debug('EthicalAds are loaded');.

Additional Context

  • Browser and version: Google Chrome Version 132.0.6834.83 (Official Build) (64-bit)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions