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

Fix NPE during SSR when style block is empty #887

Merged
merged 1 commit into from
Aug 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/optimizer/lib/transformers/ApplyCommonAttributes.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ class ApplyCommonAttributes {
'amp-custom': '',
});
appendChild(head, customStyles);
}
if (customStyles.children.length === 0) {
insertText(customStyles, '');
}
customStyles.children[0].data += styles;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<html ⚡ i-amphtml-layout i-amphtml-no-boilerplate>
<head><style amp-runtime></style>
<script async src="https://cdn.ampproject.org/v0.js"></script>
<script async custom-element="amp-img" src="https://cdn.ampproject.org/v0/amp-img-0.1.js"></script>


<link href="https://example.com/favicon.ico" rel="icon">
<style amp-custom>@media not all and (min-width: 650px){#i-amp-0{display:none}}</style>
</head>
<body>
<amp-img src="image2.jpg" height="355" width="466" class="i-amphtml-layout-fixed i-amphtml-layout-size-defined" style="width:466px;height:355px;" i-amphtml-layout="fixed" id="i-amp-0"></amp-img>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<html ⚡>
<head>
<script async src=https://cdn.ampproject.org/v0.js></script>
<script async custom-element=amp-img src=https://cdn.ampproject.org/v0/amp-img-0.1.js></script>
<noscript><style amp-boilerplate>body{-webkit-animation:none;-moz-animation:none;-ms-animation:none;animation:none}</style></noscript>
<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>
<link href=https://example.com/favicon.ico rel=icon>
<style amp-custom></style>
</head>
<body>
<amp-img media="(min-width: 650px)" src="image2.jpg" height="355" width="466"></amp-img>
</body>
</html>