Skip to content

Commit

Permalink
Remove empty attrs. (WordPress#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

0 comments on commit 8fa0d97

Please sign in to comment.