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
Copy file name to clipboardExpand all lines: plugins/optimization-detective/class-od-html-tag-processor.php
+22-20Lines changed: 22 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -246,43 +246,40 @@ final class OD_HTML_Tag_Processor extends WP_HTML_Tag_Processor {
246
246
/**
247
247
* Finds the next tag.
248
248
*
249
-
* Unlike the base class, this subclass disallows querying. This is to ensure the breadcrumbs can be tracked.
250
-
* It will _always_ visit tag closers.
249
+
* Unlike the base class, this subclass currently visits tag closers by default.
250
+
* However, for the 1.0.0 release this method will behave the same as the method in
251
+
* the base class, where it skips tag closers by default.
251
252
*
252
253
* @inheritDoc
253
254
* @since 0.4.0
255
+
* @since n.e.x.t Passing a $query is now allowed. In the 1.0.0 release, this will default to skipping tag closers.
254
256
*
255
-
* @param array{tag_name?: string|null, match_offset?: int|null, class_name?: string|null, tag_closers?: string|null}|null $query Query, but only null is accepted for this subclass.
* @throws InvalidArgumentException If attempting to pass a query.
259
259
*/
260
260
publicfunctionnext_tag( $query = null ): bool {
261
-
if ( null !== $query ) {
262
-
thrownewInvalidArgumentException( esc_html__( 'Processor subclass does not support queries.', 'optimization-detective' ) );
261
+
if ( null === $query ) {
262
+
$query = array( 'tag_closers' => 'visit' );
263
+
$this->warn(
264
+
__METHOD__,
265
+
esc_html__( 'Previously this method always visited tag closers and did not allow a query to be supplied. Now, however, a query can be supplied. To align this method with the behavior of the base class, a future version of this method will default to skipping tag closers.', 'optimization-detective' )
266
+
);
263
267
}
264
-
265
-
// Elements in the Admin Bar are not relevant for optimization, so this loop ensures that no tags in the Admin Bar are visited.
// Never process anything inside NOSCRIPT since it will never show up in the DOM when scripting is enabled, and thus it can never be detected nor measured.
287
-
if ( in_array( 'NOSCRIPT', $processor->get_breadcrumbs(), true ) ) {
287
+
// Similarly, elements in the Admin Bar are not relevant for optimization, so this loop ensures that no tags in the Admin Bar are visited.
0 commit comments