Skip to content

Commit

Permalink
Do not require display:block on relative-body styles (ampproject#6365)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dima Voytenko authored and Vanessa Pasque committed Dec 22, 2016
1 parent 78a9cbe commit a5c5542
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
1 change: 0 additions & 1 deletion css/amp.css
Expand Up @@ -85,7 +85,6 @@ html.-amp-ios-embed {

#i-amp-html-wrapper > body {
position: relative !important;
display: block !important;
/* Border is necessary to avoid margins collapsing outside body.
Alternatively we can also set overflow to hidden. */
border-top: 1px solid transparent !important;
Expand Down
1 change: 0 additions & 1 deletion src/service/viewport-impl.js
Expand Up @@ -919,7 +919,6 @@ export class ViewportBindingNatural_ {
// merging this style into `amp.css`.
if (isExperimentOn(this.win, 'make-body-relative')) {
setStyles(body, {
display: 'block',
position: 'relative',
});
}
Expand Down
6 changes: 4 additions & 2 deletions test/functional/test-viewport.js
Expand Up @@ -1026,7 +1026,7 @@ describe('ViewportBindingNatural', () => {
it('should configure make-body-relative', () => {
toggleExperiment(windowApi, 'make-body-relative', true);
binding = new ViewportBindingNatural_(windowApi, viewer);
expect(documentBody.style.display).to.equal('block');
expect(documentBody.style.display).to.be.undefined;
expect(documentBody.style.position).to.equal('relative');
// It's important that this experiment does NOT override the previously
// set `overflow`.
Expand Down Expand Up @@ -1493,6 +1493,7 @@ describes.realWin('ViewportBindingIosEmbedWrapper', {ampCss: true}, env => {
});

it('should have CSS setup', () => {
win.document.body.style.display = 'table';
const htmlCss = win.getComputedStyle(win.document.documentElement);
const wrapperCss = win.getComputedStyle(binding.wrapper_);
const bodyCss = win.getComputedStyle(win.document.body);
Expand Down Expand Up @@ -1520,7 +1521,8 @@ describes.realWin('ViewportBindingIosEmbedWrapper', {ampCss: true}, env => {

// `body` must have `relative` positioning and `block` display.
expect(bodyCss.position).to.equal('relative');
expect(bodyCss.display).to.equal('block');
// Preserve the customized `display` value.
expect(bodyCss.display).to.equal('table');

// `body` must have a 1px transparent body for two purposes:
// (1) to cancel out margin collapse in body's children;
Expand Down

0 comments on commit a5c5542

Please sign in to comment.