Skip to content

amp-date-display inside amp-list does not render correctly #23731

@dritter

Description

@dritter

There are multiple problems with amp-date-display inside an amp-list:

  1. The validator fails to detect amp-date-display in mustache templates ("The extension 'amp-date-display' was found on this page, but is unused. Please remove this extension."):
<!doctype html>
<html >
<head>
  <meta charset="utf-8">
  <title>My AMP Page</title>
  <link rel="canonical" href="self.html" />
  <meta name="viewport" content="width=device-width,minimum-scale=1">
  <style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
  <script async src="https://cdn.ampproject.org/v0.js"></script>
  <script async custom-element="amp-list" src="https://cdn.ampproject.org/v0/amp-list-0.1.js"></script>
  <script async custom-template="amp-mustache" src="https://cdn.ampproject.org/v0/amp-mustache-0.2.js"></script>
  <script async custom-element="amp-date-display" src="https://cdn.ampproject.org/v0/amp-date-display-0.1.js"></script>
  <style amp-custom>
    h1 {
      margin: 1rem;
    }
  </style>
</head>
<body>
  <h1>Hello AMPHTML World!</h1>
  <amp-list src="https://cors-test.appspot.com/test"
            single-item
            items="."
            layout="fixed-height"
            height="50">
    
    <script type="text/plain" template="amp-mustache">
      <amp-date-display datetime="2006-02-14T15:27:33+01:00" layout="fixed-height" height="20">
      	<template type="amp-mustache">  	
          <small>{{ day }}.{{ month }}.{{ year }} {{ hourTwoDigit }}:{{ minuteTwoDigit }}</small>
		</template>
      </amp-date-display>
    </script>
  </amp-list>
  
</body>
</html>
  1. amp-date-display fails to render if written inside of an amp-list:
    Screenshot_20190806_172540
<!doctype html>
<html >
<head>
  <meta charset="utf-8">
  <title>My AMP Page</title>
  <link rel="canonical" href="self.html" />
  <meta name="viewport" content="width=device-width,minimum-scale=1">
  <style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
  <script async src="https://cdn.ampproject.org/v0.js"></script>
  <script async custom-element="amp-list" src="https://cdn.ampproject.org/v0/amp-list-0.1.js"></script>
  <script async custom-template="amp-mustache" src="https://cdn.ampproject.org/v0/amp-mustache-0.2.js"></script>
  <script async custom-element="amp-date-display" src="https://cdn.ampproject.org/v0/amp-date-display-0.1.js"></script>
  <style amp-custom>
    h1 {
      margin: 1rem;
    }
  </style>
</head>
<body>
  <h1>Hello AMPHTML World!</h1>
  <amp-list src="https://cors-test.appspot.com/test"
            single-item
            items="."
            layout="fixed-height"
            height="50">
    
    <script type="text/plain" template="amp-mustache">
      This should be a proper formatted date:
      <amp-date-display datetime="2006-02-14T15:27:33+01:00" layout="fixed-height" height="20">
      	<template type="amp-mustache">  	
          <small>{{ day }}.{{ month }}.{{ year }} {{ hourTwoDigit }}:{{ minuteTwoDigit }}</small>
		</template>
      </amp-date-display>
    </script>
  </amp-list>
  This is outside of amp-list:
  <amp-date-display datetime="2012-02-14T15:27:33+01:00" layout="fixed-height" height="20">
    <template type="amp-mustache">  	
      <small>{{ day }}.{{ month }}.{{ year }} {{ hourTwoDigit }}:{{ minuteTwoDigit }}</small>
    </template>
  </amp-date-display>
</body>
</html>
  1. amp-date-display fails to render completely if the template is written in the alternative syntax (<script type="text/plain" template="amp-mustache">). This is not allowed by the validator and probably a general error. <script> inside is not allowed. Only the other way around is allowed.
    <!doctype html>
    <html >
    <head>
      <meta charset="utf-8">
      <title>My AMP Page</title>
      <link rel="canonical" href="self.html" />
      <meta name="viewport" content="width=device-width,minimum-scale=1">
      <style amp-boilerplate>body{-webkit-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-moz-animation:-amp-start 8s steps(1,end) 0s 1 normal both;-ms-animation:-amp-start 8s steps(1,end) 0s 1 normal both;animation:-amp-start 8s steps(1,end) 0s 1 normal both}@-webkit-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-moz-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-ms-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@-o-keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}@keyframes -amp-start{from{visibility:hidden}to{visibility:visible}}</style><noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
      <script async src="https://cdn.ampproject.org/v0.js"></script>
      <script async custom-element="amp-list" src="https://cdn.ampproject.org/v0/amp-list-0.1.js"></script>
      <script async custom-template="amp-mustache" src="https://cdn.ampproject.org/v0/amp-mustache-0.2.js"></script>
      <script async custom-element="amp-date-display" src="https://cdn.ampproject.org/v0/amp-date-display-0.1.js"></script>
      <style amp-custom>
        h1 {
          margin: 1rem;
        }
      </style>
    </head>
    <body>
      <h1>Hello AMPHTML World!</h1>
      <amp-list src="https://cors-test.appspot.com/test"
                single-item
                items="."
                layout="fixed-height"
                height="50">
        <template type="amp-mustache">
          <amp-date-display datetime="2006-02-14T15:27:33+01:00" layout="fixed-height" height="20">
          	<script type="text/plain" template="amp-mustache">
            
              <small>{{ day }}.{{ month }}.{{ year }} {{ hourTwoDigit }}:{{ minuteTwoDigit }}</small>
            </script>
          </amp-date-display>
        </template>
      </amp-list>
      
    </body>
    </html>

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions