Skip to content

Commit

Permalink
Remove empty attrs. (#54496)
Browse files Browse the repository at this point in the history
* Remove empty attrs.

* Fix linter errors

---------

Co-authored-by: Sarah Norris <[email protected]>
  • Loading branch information
spacedmonkey and mikachan authored Oct 13, 2023
1 parent f07b815 commit 8fa0d97
Showing 1 changed file with 6 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ class WP_Block_Parser {
*/
public $stack;

/**
* Empty associative array, here due to PHP quirks
*
* @since 4.4.0
* @var array empty associative array
*/
public $empty_attrs;

/**
* Parses a document and returns a list of block structures
*
Expand All @@ -69,11 +61,10 @@ class WP_Block_Parser {
* @return array[]
*/
public function parse( $document ) {
$this->document = $document;
$this->offset = 0;
$this->output = array();
$this->stack = array();
$this->empty_attrs = array();
$this->document = $document;
$this->offset = 0;
$this->output = array();
$this->stack = array();

while ( $this->proceed() ) {
continue;
Expand Down Expand Up @@ -287,7 +278,7 @@ public function next_token() {
*/
$attrs = $has_attrs
? json_decode( $matches['attrs'][0], /* as-associative */ true )
: $this->empty_attrs;
: array();

/*
* This state isn't allowed
Expand Down Expand Up @@ -318,7 +309,7 @@ public function next_token() {
* @return WP_Block_Parser_Block freeform block object.
*/
public function freeform( $inner_html ) {
return new WP_Block_Parser_Block( null, $this->empty_attrs, array(), $inner_html, array( $inner_html ) );
return new WP_Block_Parser_Block( null, array(), array(), $inner_html, array( $inner_html ) );
}

/**
Expand Down

1 comment on commit 8fa0d97

@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 in 8fa0d97.
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/6514090157
📝 Reported issues:

Please sign in to comment.