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-style.php

    r60729 r61020  
    191191            >Text</div>';
    192192        list($p) = $this->process_directives( $html );
    193         $this->assertSame( 'color:green;background:green;', $p->get_attribute( 'style' ) );
     193        $this->assertSame( 'background:green;color:green;', $p->get_attribute( 'style' ) );
    194194    }
    195195
     
    449449        $this->assertNull( $p->get_attribute( 'style' ) );
    450450    }
     451
     452    /**
     453     * Tests it can use CSS variables.
     454     *
     455     * @ticket 64106
     456     *
     457     * @covers ::process_directives
     458     */
     459    public function test_wp_style_can_use_CSS_variables() {
     460        $html    = '<div data-wp-style----text-color="myPlugin::state.green">Text</div>';
     461        list($p) = $this->process_directives( $html );
     462        $this->assertSame( '--text-color:green;', $p->get_attribute( 'style' ) );
     463    }
     464
     465    /**
     466     * Tests it ignores unique IDs.
     467     *
     468     * @ticket 64106
     469     *
     470     * @covers ::process_directives
     471     */
     472    public function test_wp_style_ignores_unique_ids() {
     473        $html    = '<div data-wp-style--color---unique-id="myPlugin::state.green">Text</div>';
     474        list($p) = $this->process_directives( $html );
     475        $this->assertNull( $p->get_attribute( 'style' ) );
     476    }
    451477}
Note: See TracChangeset for help on using the changeset viewer.