ampproject / ampproject/amphtml

<amp-autocomplete> Validator sometimes throws error even though it's the same html code and valid amp-autocomplete

Open
#31,605 3 comments 0 reactions 0 assignees View on GitHub
Component: amp-autocomplete Stale Type: Bug WG: components
Dominant language
JavaScript
Stars
14.9k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

## What's the issue?

fires error on page load when it shouldn't

Uncaught (in promise) Resource: failed to build: amp-autocomplete#20: amp-autocomplete should contain exactly one or descendant amp-autocomplete

## How do we reproduce the issue?

1. Go to https://cartia.ro/carti/pentru-Tineri_intre_13_si_18_ani
2. Look at console, sometimes it works with now errors, but on some refreshes, it throws the error
3. the input is always present in <amp-autocomplete>

## What browsers are affected?

Tested on Chrome Version 87.0.4280.88 (Official Build) (x86_64)

## Which AMP version is affected?

Powered by AMP ⚡ HTML – Version 2011252111002 https://cartia.ro/carti/pentru-Tineri_intre_13_si_18_ani

We are transitioning to AMP framework but we do it progressive, so there are still some amp errors, we tried this with no other JS besides AMP and it's still reproducible.

I looked into the amp-autocomplete code and the only thing that may happen is maybe the DOM is not fully initialized yet when amp-autocomplete runs the querySelectorAll() or since the method returns a static (not live) list, it may not be "ready" yet?

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue on the provided cartia.ro page, then inspect the amp-autocomplete validation path around querySelectorAll(). Done means valid markup consistently loads without the erroneous descendant-count error across refreshes.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.