You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<?phpesc_html_e( 'Automatically remove CSS rules that are not relevant to a given page (tree shaking).', 'amp' ); ?>
331
-
</label>
332
-
</p>
333
-
<p class="description">
334
-
<?phpesc_html_e( 'AMP limits the total amount of CSS to no more than 50KB; any more than this will cause a validation error. The need to tree shake the CSS is not done by default because in some situations (in particular for dynamic content) it can result in CSS rules being removed that are needed.', 'amp' ); ?>
335
-
</p>
336
-
</div>
337
-
<?phpendif; ?>
338
-
339
316
<script>
340
317
(function( $ ) {
341
318
var getThemeSupportMode = function() {
@@ -346,21 +323,14 @@ public function render_validation_handling() {
@@ -87,15 +80,13 @@ class AMP_Style_Sanitizer extends AMP_Base_Sanitizer {
87
80
* Array of flags used to control sanitization.
88
81
*
89
82
* @var array {
90
-
* @type string $remove_unused_rules Enum 'never', 'sometimes' (default), 'always'. If total CSS is greater than max_bytes, whether to strip selectors (and then empty rules) when they are not found to be used in doc. A validation error will be emitted when stripping happens since it is not completely safe in the case of dynamic content.
91
83
* @type string[] $dynamic_element_selectors Selectors for elements (or their ancestors) which contain dynamic content; selectors containing these will not be filtered.
92
84
* @type bool $use_document_element Whether the root of the document should be used rather than the body.
* @type bool $allow_dirty_styles Allow dirty styles. This short-circuits the sanitize logic; it is used primarily in Customizer preview.
95
87
* @type callable $validation_error_callback Function to call when a validation error is encountered.
96
88
* @type bool $should_locate_sources Whether to locate the sources when reporting validation errors.
97
89
* @type string $parsed_cache_variant Additional value by which to vary parsed cache.
98
-
* @type bool $accept_tree_shaking Whether to accept tree-shaking by default and bypass a validation error.
99
90
* @type string $include_manifest_comment Whether to show the manifest HTML comment in the response before the style[amp-custom] element. Can be 'always', 'never', or 'when_excessive'.
100
91
* }
101
92
*/
@@ -107,7 +98,6 @@ class AMP_Style_Sanitizer extends AMP_Base_Sanitizer {
107
98
* @var array
108
99
*/
109
100
protected$DEFAULT_ARGS = array(
110
-
'remove_unused_rules' => 'sometimes',
111
101
'dynamic_element_selectors' => array(
112
102
'amp-list',
113
103
'amp-live-list',
@@ -116,7 +106,6 @@ class AMP_Style_Sanitizer extends AMP_Base_Sanitizer {
116
106
),
117
107
'should_locate_sources' => false,
118
108
'parsed_cache_variant' => null,
119
-
'accept_tree_shaking' => false,
120
109
'include_manifest_comment' => 'always',
121
110
);
122
111
@@ -298,7 +287,6 @@ public static function get_css_parser_validation_error_codes() {
298
287
self::ILLEGAL_AT_RULE_ERROR_CODE,
299
288
'illegal_css_important',
300
289
'illegal_css_property',
301
-
self::TREE_SHAKING_ERROR_CODE,
302
290
'unrecognized_css',
303
291
'disallowed_file_extension',
304
292
'file_path_not_found',
@@ -2388,7 +2376,7 @@ private function collect_inline_styles( $element ) {
2388
2376
/**
2389
2377
* Finalize stylesheets for style[amp-custom] and style[amp-keyframes] elements.
2390
2378
*
2391
-
* Concatenate all pending stylesheets, remove unused rules if necessary, and add to style elements in doc.
2379
+
* Concatenate all pending stylesheets, remove unused rules, and add to AMP style elements in document.
2392
2380
* Combine all amp-keyframe styles and add them to the end of the body.
2393
2381
*
2394
2382
* @since 1.0
@@ -2398,19 +2386,15 @@ private function finalize_styles() {
$stylesheet_groups[ $pending_stylesheet['group'] ]['total_size'] += $size; // Used in finalize_stylesheet_group() to determine if tree shaking is needed.
2437
2420
2438
2421
if ( ! empty( $pending_stylesheet['imported_font_urls'] ) ) {
0 commit comments