Skip to content

Commit

Permalink
Remove first draft select function
Browse files Browse the repository at this point in the history
  • Loading branch information
dmsnell committed Jan 6, 2023
1 parent 30172ab commit f415bdb
Showing 1 changed file with 0 additions and 121 deletions.
121 changes: 0 additions & 121 deletions lib/experimental/html/class-wp-html-attribute-sourcer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit f415bdb

Please sign in to comment.