wordpress-develop icon indicating copy to clipboard operation
wordpress-develop copied to clipboard

Interactivity API: Fix `data-wp-bind` to continue processing valid directives after encountering invalid ones

Open luisherranz opened this issue 4 days ago • 2 comments

What

This PR fixes a bug in the data_wp_bind_processor method where a return statement inside a foreach loop was causing the function to exit entirely when encountering a bind directive with an empty suffix or a unique ID.

Why

When an element has multiple data-wp-bind directives, such as:

<div data-wp-bind="myPlugin::state.id" data-wp-bind--id="myPlugin::state.id">Text</div>

The first directive (data-wp-bind with no suffix) is invalid and should be skipped. However, the return statement was causing the entire function to exit, preventing the valid data-wp-bind--id directive from being processed.

How

Changed return to continue so that invalid entries are skipped while valid entries continue to be processed.


Trac ticket: https://core.trac.wordpress.org/ticket/64518


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

luisherranz avatar Jan 16 '26 09:01 luisherranz