Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
logocomune opened this issue Jan 18, 2025 · 2 comments
Open

Comments

@logocomune
Copy link

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)
@ericholscher
Copy link
Member

Do you have a URL where we can see this behavior?

@logocomune
Copy link
Author

I have narrowed down the issue. The event occurs when I use the tag data-ea-manual="false".

I created a JSBin with an example where I deliberately set an incorrect data-ea-publisher (but placements end up being [null] even if the publisher is set to "test").

However, when it is set with data-ea-manual="false", everything works correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants