Allow `!important` qualifiers in `style[amp-noscript]`
See original GitHub issueDescription
This is a follow-up to #20609.
In order to ensure that amp-accordion
sections are initially-expanded on a page in which the user has JS turned off, the following is needed:
<noscript>
<style amp-noscript>
amp-accordion > section:not([expanded]) > :last-child {
display: block !important;
}
</style>
</noscript>
Example: https://bento-amp-noscript-styles.glitch.me/ See: https://github.com/ampproject/amphtml/issues/20609#issuecomment-901426550
The !important
is needed here in order to override this !important
style from ampshared.css
:
However, this is not currently feasible since the use of !important
qualifiers is not allowed in style[amp-noscript]
:
Usage of the !important CSS qualifier is not allowed.
I propose that they be allowed in the same way they are allowed in style[amp-runtime]
.
Interestingly, allow_important: true
doesn’t appear in style[amp-runtime]
:
Just as it doesn’t appear in style[amp-noscript]
:
Perhaps allow_important
is only considered for rules that are enabled_by: "transformed"
?
Alternatives Considered
None.
Additional Context
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (5 by maintainers)
I implemented this back in January, the issue was just never closed.
@jcastilloa you are probably running into issues around using
!important
in<style>
tags outside of<noscript>
, which is different and intended.@westonruter for
<style amp-runtime ...>
note that there is nocdata
set in the TagSpec. Basically anything can be in the cdata for that. This is permitted as AMP Caches will rewrite thecdata
with the corresponding AMP CSS with the AMP Runtime version that is being served by that AMP Cache. Also the AMP Runtime will rewrite the AMP CSS if necessary.So
allow_important
would need to be set to thecdata
for<style amp-noscript>
TagSpec.