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

<amp-script> must not be empty #24265

Closed
fstanis opened this issue Aug 28, 2019 · 4 comments · Fixed by #26444
Closed

<amp-script> must not be empty #24265

fstanis opened this issue Aug 28, 2019 · 4 comments · Fixed by #26444

Comments

@fstanis
Copy link
Contributor

fstanis commented Aug 28, 2019

What's the issue?

If <amp-script> is empty (doesn't contain any initial content), then no attempt is made to load it and no error is throws.

How do we reproduce the issue?

<amp-script layout="container" src="/anything.js"></amp-script>

This should either:

  • Make an attempt to fetch /anything.js
  • Result in runtime error
  • Result in validator error

Which AMP version is affected?

1908222134250

@nainar
Copy link
Contributor

nainar commented Sep 16, 2019

This is a developer affordance we should definitely have to set them on the correct path. Marking it as a P1 as such.

@dreamofabear
Copy link

I think this is actually due to the amp-script element having a width/height of zero. Such elements are ignored by the resource scheduling system -- layoutCallback() won't be called which initializes the element.

Is there a use case you have in mind for a child-less amp-script? E.g. I can imagine using amp-script as a data layer (using AMP.setState in the JS), though you could just add width=1 height=1 as a workaround.

@samouri
Copy link
Member

samouri commented Jan 15, 2020

I think this is actually due to the amp-script element having a width/height of zero. Such elements are ignored by the resource scheduling system -- layoutCallback() won't be called which initializes the element.

I've actually run into this as well and was confused. I was attempting to populate the <amp-script> element completely by the script's js as without having initial contents.

Forcing a nonzero width is fine, but I'd at least expect a dev warning.

@dreamofabear
Copy link

We could do that by overriding onLayoutMeasure() or onMeasureChanged() in amp-script.js and warning if the layout box has a zero size and hasn't been laid out.

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

Successfully merging a pull request may close this issue.

4 participants