[wp-trac] [WordPress Trac] #64208: Defining interactivity API context with single quotes fail

WordPress Trac noreply at wordpress.org
Thu Nov 6 09:16:27 UTC 2025


#64208: Defining interactivity API context with single quotes fail
-------------------------------+-----------------------------
 Reporter:  Fab1en             |      Owner:  (none)
     Type:  enhancement        |     Status:  new
 Priority:  normal             |  Milestone:  Awaiting Review
Component:  Interactivity API  |    Version:  6.8.3
 Severity:  minor              |   Keywords:
  Focuses:  javascript, docs   |
-------------------------------+-----------------------------
 In [https://developer.wordpress.org/block-editor/reference-guides
 /interactivity-api/api-reference/#wp-bind the documentation], we can read
 an example using double quotes to define interactivity API context :
 {{{
 <li data-wp-context='{ "isMenuOpen": false }'>
 }}}


 However, the following HTML code is also valid (using single quotes
 instead of doubles inside the object):
 {{{
 <li data-wp-context="{ 'isMenuOpen': false }">
 }}}
 But it silently fails to properly define the context. I understand that
 single quotes are not valid in JSON, but I think that it should raise an
 error.

 I think it should also be mentioned more explicitly in
 [https://developer.wordpress.org/block-editor/reference-guides
 /interactivity-api/api-reference/#wp-context the documentation] : to
 define a context with double quotes inside, one should surround it with
 single quotes, whereas all other HTML attributes definitions are
 surrounded by double quotes.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/64208>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list