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 Dec 24, 2022
1 parent 6002cfd commit e2d2d8e
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

1 comment on commit e2d2d8e

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3769922447
📝 Reported issues:

Please sign in to comment.