Skip to content

[amp-bind] amp-list evaluation does not wait for amp-state's src request to be resolved #11998

Description

@sebastianbenz

Bindings are evaluated when an amp-list template is rendered. However, these bindings don't wait until an amp-state's remote src has been resolved (which they should to ensure an deterministic behavior).

Example:

An amp-state element using a JSON endpoint:

<amp-state id="favorite"
  credentials="include"
  src="/favorite-with-count?RANDOM">
</amp-state>

The amp-list binds an element to the amp-state:

<amp-list ... src="/favorite-with-count?RANDOM">
    <template type="amp-mustache">
        <div class="favorite-count" [text]="favoriteWithCount.count ? favoriteWithCount.count : ''">{{count}}</div>
    </template>
  </amp-list>

This results in a race-condition, where the text is either null or 123 depending on whether the amp-state has already been resolved or not.

I noticed this while working on this sample: https://ampbyexample.com/advanced/favorite_button/

//cc @choumx @ericlindley-g

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions