Make WordPress Core


Ignore:
Timestamp:
10/21/2025 12:07:16 PM (4 months ago)
Author:
luisherranz
Message:

Interactivity API: Support unique IDs in server-side directives processing.

Server-side logic to support unique IDs in the Interactivity API directives to match what the client is doing (https://github.com/WordPress/gutenberg/pull/72161).

Props santosguillamot, darerodz, luisherranz.
Fixes #64106.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/interactivity-api/wpInteractivityAPI-wp-class.php

    r58594 r61020  
    7777            >Text</div>';
    7878        list($p) = $this->process_directives( $html );
    79         $this->assertSame( 'some-class other-class', $p->get_attribute( 'class' ) );
     79        $this->assertSame( 'other-class some-class', $p->get_attribute( 'class' ) );
    8080    }
    8181
     
    329329        $this->assertNull( $p->get_attribute( 'class' ) );
    330330    }
     331
     332    /**
     333     * Tests that classes with several dashes can be used.
     334     *
     335     * @ticket 64106
     336     *
     337     * @covers ::process_directives
     338     */
     339    public function test_wp_class_can_use_several_dashes() {
     340        $html    = '<div data-wp-class--main-bg--color="myPlugin::state.true">Text</div>';
     341        list($p) = $this->process_directives( $html );
     342        $this->assertSame( 'main-bg--color', $p->get_attribute( 'class' ) );
     343
     344        $html    = '<div data-wp-class--main-bg---color="myPlugin::state.true">Text</div>';
     345        list($p) = $this->process_directives( $html );
     346        $this->assertSame( 'main-bg---color', $p->get_attribute( 'class' ) );
     347
     348        $html    = '<div data-wp-class--main-bg----color="myPlugin::state.true">Text</div>';
     349        list($p) = $this->process_directives( $html );
     350        $this->assertSame( 'main-bg----color', $p->get_attribute( 'class' ) );
     351    }
    331352}
Note: See TracChangeset for help on using the changeset viewer.