amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

<amp-list>'s src attribute gets changed dynamically in error

Open micyeung opened this issue 8 years ago • 6 comments

Using an amp-list in combination with amp-form in a "Show More" pattern similar to the demo in AMP by Example, we find that the src attribute in amp-list gets dynamically changed to a meaningless URL like the following: https://ampbyexample.com/samples_templates/product_page/preview/[object%20Object],[object%20Object],[object%20Object],[object%20Object],[object%20Object],[object%20Object],[object%20Object],[object%20Object],[object%20Object]

This results in a meaningless request being sent to the server. For large e-commerce sites, this can add up to a huge additional load to the server.

How do we reproduce the issue?

Go to https://ampbyexample.com/samples_templates/product_page/preview/, scroll down to the list, Click "Show More". Notice the URL change in src in amp-list.

See steps in the attached GIF. amp-list

micyeung avatar Jan 16 '18 06:01 micyeung

@micyeung are you sure the URL requests are those you see in the code? I was expecting the network calls in the Chrome console and I don't see those parameters there

kul3r4 avatar Jan 16 '18 16:01 kul3r4

I'm seeing the same thing that @kul3r4 sees in this example page--the src attribute of the amp-list updates with those "[object Object]"s, but the XHRs that are made go to the more_related_products_page as specified in the amp-list form action.

I am curious why we're updating the src in that way.

mrjoro avatar Jan 16 '18 17:01 mrjoro

Although src is changing, it is actually not triggering a network request (since it is local state binding from the result of the form submit).

@choumx This case is using local state binding but src value of the amp-list is also being updated. For debugging and cosmitic purposes, we may want to skip updating the src in DOM when local binding is used.

aghassemi avatar Jan 16 '18 18:01 aghassemi

Created https://github.com/ampproject/amphtml/issues/12850 for the smaller issue that src is changed to meaningless value.

Closing this issue for https://github.com/ampproject/amphtml/issues/12850

aghassemi avatar Jan 16 '18 21:01 aghassemi

@choumx So can this actually cause 404's if amp-list is layedout after a mutation with locale state?

aghassemi avatar Jan 16 '18 23:01 aghassemi

@aghassemi I believe yes.

dreamofabear avatar Jan 17 '18 01:01 dreamofabear