[wp-trac] [WordPress Trac] #25280: wp_localize_script unexpectedly converts numbers to strings

WordPress Trac noreply at wordpress.org
Sun Apr 15 18:23:13 UTC 2018


#25280: wp_localize_script unexpectedly converts numbers to strings
------------------------------------+-----------------------------
 Reporter:  adamsilverstein         |       Owner:  (none)
     Type:  enhancement             |      Status:  new
 Priority:  normal                  |   Milestone:  Future Release
Component:  Script Loader           |     Version:  3.2
 Severity:  normal                  |  Resolution:
 Keywords:  has-patch dev-feedback  |     Focuses:  javascript
------------------------------------+-----------------------------

Comment (by jason_the_adams):

 Just discovered this by creating a duplicate ticket. I'd like to pass long
 a couple of my points and chime in.

 Part of what makes this so painful is that we're dealing with a very
 commonly used built-in method that's not terribly well built. The method
 supports objects/arrays, but not very well. The casting and decoding only
 happen on the root level, so while we're concerned about backwards-
 compatibility, the existing functionality is inconsistent.

 I appreciate the tension between wanting a function that produces reliable
 server-to-browser JSON, but also don't want to break the existing
 codebases.

 So I support @adamsilverstein 's idea to add recursion to the existing
 functionality and break out a new helper. I think, though, that there may
 be more decisions to be made regarding adding the recursion than the
 helper. So perhaps that should be broken out into its own ticket so we can
 get this helper added sooner than later.

 Would love to see that helper get into core!

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/25280#comment:34>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list