From f415bdba0a34c8fb5444f7ba6a093ff45fe81b5a Mon Sep 17 00:00:00 2001 From: Dennis Snell Date: Fri, 23 Dec 2022 23:01:11 -0600 Subject: [PATCH] Remove first draft select function --- .../html/class-wp-html-attribute-sourcer.php | 121 ------------------ 1 file changed, 121 deletions(-) diff --git a/lib/experimental/html/class-wp-html-attribute-sourcer.php b/lib/experimental/html/class-wp-html-attribute-sourcer.php index 27a78aecffd77..ea178cbf2eafd 100644 --- a/lib/experimental/html/class-wp-html-attribute-sourcer.php +++ b/lib/experimental/html/class-wp-html-attribute-sourcer.php @@ -236,127 +236,6 @@ public static function select( $selectors, $html ) { return false; } - public static function select_draft1( $selectors, $html ) { - $tags = new WP_HTML_Processor( $html ); - if ( ! $tags->next_tag() ) { - return null; - } - - $tags->set_bookmark( 'start' ); - - foreach ( $selectors as $s ) { - $tags->seek( 'start' ); - $max = 100; - while ( --$max > 0 ) { - $next = $s; - - // This label is probably where some stack-level data should reside. - next: - // Find the next starting point - while ( null === self::select_match( $tags, $next ) && $tags->next_tag() ) { - continue; - } - - // We're out of possible starting points - if ( null === self::select_match( $tags, $next ) ) { - continue 2; - } - - // No further selectors, then bingo! - if ( ! isset( $next['then'] ) ) { - return $tags; - } - - $next = $next['then']; - - // Adjacent sibling must be the immediately-following element. - if ( '+' === $next['combinator'] ) { - var_dump( [ - 'msg' => "Processing adjacent sibling", - 'html' => $html, - 'tag' => $tags->get_tag(), - 'selector' => $next - ] ); - $state = $tags->new_state(); - while ( $tags->balanced_next( $state ) ) { - continue; - } - - $tags->next_tag(); - if ( null === self::select_match( $tags, $next ) ) { - continue; - } - - if ( isset( $next['then'] ) ) { - goto next; - } - - // @TODO: Recurse here so we can handle more than one level. - return $tags; - } - - // Child must be one level into current tag. - if ( '>' === $next['combinator'] ) { - var_dump( [ - 'msg' => "Processing child", - 'html' => $html, - 'tag' => $tags->get_tag(), - 'selector' => $next - ] ); - $state = $tags->new_state(); - $state->match_depth = 1; - while ( $tags->balanced_next( $state ) ) { - if ( null === self::select_match( $tags, $next ) ) { - continue; - } - - if ( isset( $next['then'] ) ) { - goto next; - } - - // @TODO: Recurse here so we can handle more than one level. - return $tags; - } - - continue; - } - - // Descendant can be anywhere inside current tag. - if ( ' ' === $next['combinator'] ) { - var_dump( [ - 'msg' => "Processing descendant", - 'html' => $html, - 'tag' => $tags->get_tag(), - 'selector' => $next - ] ); - $state = $tags->new_state(); - while ( $tags->balanced_next( $state ) ) { - if ( null === self::select_match( $tags, $next ) ) { - continue; - } - - if ( isset( $next['then'] ) ) { - goto next; - } - - // @TODO: Recurse here so we can handle more than one level. - return $tags; - } - - continue; - } - - // General sibling must be anything at current level. - if ( '~' === $next['combinator'] ) { - // @TODO: Support this. - return null; - } - } - } - - return null; - } - public static function parse_definition( $definition ) { if ( empty( $definition['source'] ) ) { return 'not-sourced';