Opened 6 weeks ago
Closed 4 weeks ago
#61741 closed defect (bug) (fixed)
Interactivity API: Directives cannot access derived state properties on the server
Reported by: | jonsurrell | Owned by: | luisherranz |
---|---|---|---|
Milestone: | 6.6.2 | Priority: | normal |
Severity: | normal | Version: | 6.6 |
Component: | Interactivity API | Keywords: | has-patch has-unit-tests dev-reviewed |
Focuses: | Cc: |
Description
If a directives includes derived state in a non-final position, and this is implemented with server-side derived state, this causes an error and the directive is not processed correctly. For example:
<p data-wp-text="state.derivedState.property"></p>
Where the state might look something like this:
<?php array( 'derivedState' => function() { return array( 'property' => 'Hello, world!' ); }, );
This will error and fail to process correctly on the server. On the client with derived state getters, this will work fine.
Change History (12)
This ticket was mentioned in PR #7075 on WordPress/wordpress-develop by @jonsurrell.
6 weeks ago
#1
- Keywords has-patch added
This ticket was mentioned in Slack in #core-committers by luisherranz. View the logs.
6 weeks ago
#4
@
6 weeks ago
- Owner set to luisherranz
- Resolution set to fixed
- Status changed from new to closed
In 58825:
@luisherranz commented on PR #7075:
6 weeks ago
#5
Committed to Core in https://core.trac.wordpress.org/changeset/58825.
Thanks, Jon 🙂
#6
@
6 weeks ago
- Keywords dev-feedback added
- Resolution fixed deleted
- Status changed from closed to reopened
Reopening for 6.6.2 consideration.
#7
follow-up:
↓ 8
@
6 weeks ago
PR looks good to me @luisherranz - should the @since
line read 6.6.2? +1 to backporting.
#8
in reply to:
↑ 7
@
6 weeks ago
Replying to adamsilverstein:
should the
@since
line read 6.6.2? +1 to backporting.
Support for derived state on the server was added in 6.6.0. I added @since 6.6.0
intentionally since it was omitted when the feature was introduced.
This ticket was mentioned in Slack in #core-committers by luisherranz. View the logs.
5 weeks ago
#10
@
5 weeks ago
- Keywords dev-reviewed added; dev-feedback removed
It looks good to backport to WP 6.6.2.
In some cases, derived state returns and object. Directives may wish to
continue to access properties of the object. Support this behavior.
On the client, derived state is implemented as JavaScript getters. This
transparently supports traversing a directive value like this:
We can support this behavior on the server by handling derived state at
whatever the
current
value is for evaluation.Trac ticket: https://core.trac.wordpress.org/ticket/61741