Amp-wp: CSS Parser does not preserve styles used inside templates script[type=text/plain]

Created on 11 Feb 2020  路  9Comments  路  Source: ampproject/amp-wp

Bug Description

The plugin implements the removal of unused CSS rules on the page. This works well for all page content, including <template type="amp-mustache">...</template>, but does not work with <script type="text/plain" template="amp-mustache">...</script>.

Expected Behaviour

Preserve CSS rules for elements inside <script type="text/plain" template="amp-mustache">...</script>.

Steps to reproduce

  1. Add code to AMP page:
<style>
    h2.one { color: green }
    h2.two { color: red }
</style>
<template type="amp-mustache">
    <h2 class="one">One</h2>
</template>
<script type="text/plain" template="amp-mustache">
    <h2 class="two">Two</h2>
</script>
  1. View the resulting source code for an AMP page.
  2. See content <style amp-custom>...</style> in page head where there is a rule h2.one{color:green} but there is no rule h2.two{color:red}.

Additional context

  • WordPress version: 5.3.2
  • Plugin version: 1.4.2
  • AMP plugin template mode: Website; Standard; Serve all templates as AMP regardless of what is being queried.
  • PHP version: 7.3.11

Acceptance criteria

Implementation brief

QA testing instructions

Demo

Changelog entry

Bug CSS QA passed

All 9 comments

I believe this may be resolved by fixing #4254.

@westonruter thanks!

This is especially important if full support of <!--{{#foo}}--> is not implemented (issue #26656).

I believe this may be resolved by fixing #4254.

Just verified that this is indeed fixed via the PR that @kienstra did for #4254 :

Image 2020-03-02 at 6 42 36 AM

I'll add a "Fixes #4276" to that PR.

Verified in QA:

聽 | 聽
聽 |


聽 | 聽
聽 |

聽 | 聽
聽 | 聽
聽 |
聽 |
聽 |

Bug is present with plugin version 1.5 (1.5.0 and 1.5.1).

Bizzare. We did fix this. But I'm not seeing it now.

@spasibych Here鈥檚 a 1.5.2-RC1 pre-release build with the fix for you to test: amp.zip (v1.5.2-RC1-20200403T193031Z-3102c5dea)

We've just published the 1.5.2 release to WordPress.org: https://wordpress.org/plugins/amp/

You can update now via the WordPress admin.

Release notes: https://github.com/ampproject/amp-wp/releases/tag/1.5.2

@westonruter now everything is fine, thank you very much!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

maciejmackowiak picture maciejmackowiak  路  5Comments

miina picture miina  路  3Comments

swissspidy picture swissspidy  路  5Comments

westonruter picture westonruter  路  5Comments

ernee picture ernee  路  4Comments