WordPress.org

Make WordPress Core

Changes between Initial Version and Version 1 of Ticket #34893, comment 8


Ignore:
Timestamp:
12/09/2015 07:38:00 PM (4 years ago)
Author:
westonruter
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #34893, comment 8

    initial v1  
    1 Another improvement is needed on the JS side of things. Namely, the there is currently a `wp.customize.Setting.prototype.validate()` method allows you to sanitize a value and also to block the setting update if you pass back `null` to block the `Setting` (really, the `Value`). So really, the `validate` method in JS is serving in the same purpose as the `sanitize` method in PHP. They both conflate sanitization and validation.
     1Another improvement is needed on the JS side of things. Namely, there is currently a `wp.customize.Setting.prototype.validate()` method allows you to sanitize a value and also to block the setting update if you pass back `null` to block the `Setting` (really, the `Value`). So really, the `validate` method in JS is serving in the same purpose as the `sanitize` method in PHP. They both conflate sanitization and validation.
    22
    33I suggest that we extend `wp.customize.Setting` to introduce a `sanitize` method for the purpose of sanitization, and that the existing `validate` method be extended to allow for the returning of an `Error` object, which would have the same effect for blocking the value but it could also then emit an event on the `Setting` object, which could then be picked up by any controls to then display a validation error message.