Only add all Google Font style rules in editor context#3328
Merged
swissspidy merged 1 commit intodevelopfrom Sep 24, 2019
Merged
Only add all Google Font style rules in editor context#3328swissspidy merged 1 commit intodevelopfrom
swissspidy merged 1 commit intodevelopfrom
Conversation
Also fix blatant error in test_render_post_filters
This was referenced Sep 23, 2019
Merged
swissspidy
approved these changes
Sep 24, 2019
westonruter
added a commit
that referenced
this pull request
Sep 24, 2019
Also fix blatant error in test_render_post_filters Merges #3328 into 1.3 branch
Collaborator
|
QA fort this is part of #3344. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I noticed there is an
excessive_cssproblem with stories:Notice the
amp-stories-inline-csshere, being 66KB+.I rejected the validation errors to see what the underlying markup was prior to sanitizing, and it was many rules like this:
So the issue is custom font styles being added with this code:
amp-wp/includes/class-amp-story-post-type.php
Lines 833 to 839 in b44ac6a
The problem is that only the style rules for fonts that are actually being used should be added to the page. As @swissspidy this is already being done:
amp-wp/includes/class-amp-story-post-type.php
Lines 1386 to 1418 in b44ac6a
Therefore, it appears these style rules were being added redundantly in the admin editor context and they can just be moved to only be added there.
The reason why this issue would only sometimes occur is because it would only happen when someone picked a custom font. At that point, a
data-font-familyattribute would appear in the page and the style rules using selectors like[data-font-family="..."]would no longer be tree-shaken.Before
After
This also fixes blatant error in
test_render_post_filterswhich was introduced a long time ago, but for some reason it only showed up now. Fixes #3327.