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

Support disable-inline-width attribute when applying layout sizes #27083

Merged
merged 6 commits into from
Mar 16, 2020

Conversation

caroqliu
Copy link
Contributor

@caroqliu caroqliu commented Mar 4, 2020

This allows specifying the sizes on elements without getting the sizing behavior of sizes in AMP (which adds a width based on which media query matches). Addresses #21736

See discussion doc for more

spec/amp-html-layout.md Outdated Show resolved Hide resolved
src/custom-element.js Outdated Show resolved Hide resolved
Copy link
Contributor

@jridgewell jridgewell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM. I think this still needs validator changes to make it valid?

@amp-owners-bot
Copy link

Hey @ampproject/wg-caching, these files were changed:

validator/validator-main.protoascii

@caroqliu caroqliu merged commit 9dc6c03 into ampproject:master Mar 16, 2020
amaltas added a commit that referenced this pull request Mar 18, 2020
* cl/301228504 Revision bump for #27083

* cl/301306664 Revision bump for #27180

* Update validator-amp-list.out

* Update validator-amp-list.out

* Update validator-amp-list.out
twintwox pushed a commit to twintwox/amphtml that referenced this pull request Mar 24, 2020
…mpproject#27083)

* Do not apply sizes for `disable-inline-width`

* Add documentation for `disable-inline-width`

* Add amp-img test

* Update documentation

* Move attribute check to ternary

* Add attribute to validator
twintwox pushed a commit to twintwox/amphtml that referenced this pull request Mar 24, 2020
* cl/301228504 Revision bump for ampproject#27083

* cl/301306664 Revision bump for ampproject#27180

* Update validator-amp-list.out

* Update validator-amp-list.out

* Update validator-amp-list.out
@westonruter
Copy link
Member

Is this related to #17053? does the presence of disable-inline-width allow for the browser's underlying sizes behavior to be retained?

@caroqliu
Copy link
Contributor Author

caroqliu commented Apr 8, 2020

@westonruter Yes, this is related as it directly resolves the original issue filed:

This might be the expected behavior. But it looks like the <amp-img> sizes attribute causes inline styling to be added to the <amp-img>, which can distort it.

And this seems to be different from the non-AMP behavior of a sizes attribute in an <img>.

@westonruter
Copy link
Member

@caroqliu I think I may have identified something that was missed with support for disable-inline-width and that has to do with this CSS rule in ampshared.css:

.i-amphtml-layout-responsive,
[layout=responsive][width][height]:not(.i-amphtml-layout-responsive),
[width][height][sizes]:not(.i-amphtml-layout-responsive)
{
display: block;
position: relative;
}

Should not that last selector be changed to exclude elements that have the disable-inline-width attribute? Like so:

- [width][height][sizes]:not(.i-amphtml-layout-responsive)
+ [width][height][sizes]:not([disable-inline-width]):not(.i-amphtml-layout-responsive)

Otherwise, a regression is introduced by adopting disable-inline-width instead of removing the sizes attribute: ampproject/amp-wp#4622 (comment).

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

Successfully merging this pull request may close these issues.

7 participants