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 Optimzier Appears To Be Stripping AMP iFrame Common Attributes #1335

Open
SkylerRogers opened this issue Jul 15, 2022 · 0 comments
Open

Comments

@SkylerRogers
Copy link

SkylerRogers commented Jul 15, 2022

On the latest version of @ampproject/toolbox-optimizer (v2.9.0), it appears that certain iframe attributes are being stripped off the iframe. One in particular is the heights attribute.

Per the AMP docs amp-iframe should include Common Attributes, with heights being one of the supported attributes for amp-iframe.

Is there any way around this or an option to not optimize iframe elements?

Many thanks!

--

Script to reproduce:

const AmpOptimizer = require('@ampproject/toolbox-optimizer');

const ampOptimizer = AmpOptimizer.create({});

const body = `<!DOCTYPE html>
  <html lang="en" ⚡>
    <head>
      <meta charset="utf-8" />
      <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1" />
      <title>Test</title>
    </head>
    <body id="top">
      <amp-iframe
        title="My iFrame"
        width="385"
        height="179"
        heights="(min-width: 375px) 210px, 80%"
        sandbox="allow-scripts allow-same-origin allow-popups"
        layout="responsive"
        frameborder="0"
        id="myIframe"
        class="i-amphtml-element i-amphtml-layout-responsive i-amphtml-layout-size-defined i-amphtml-built i-amphtml-layout"
        src="https://www3.mydomain.com/pages/embedded-123#amp=1"
        resizable=""
        allowtransparency=""
        i-amphtml-layout="responsive"
        scrolling="no"
        style="--loader-delay-offset:0ms !important;"
      >
        <i-amphtml-sizer slot="i-amphtml-svc" style="padding-top: 210px;"></i-amphtml-sizer>
        <iframe
          class="i-amphtml-fill-content"
          name="amp_iframe0"
          allowtransparency=""
          frameborder="0"
          scrolling="no"
          title="My iFrame"
          allow=""
          sandbox="allow-scripts allow-same-origin allow-popups"
          src="https://www3.mydomain.com/pages/embedded-123#amp=1"
        >
        </iframe>
      </amp-iframe>
    </body>
  </html>`;


(async () => {
  const optimizedHtml = await ampOptimizer.transformHtml(body);
  console.log(optimizedHtml);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant