#30701 closed defect (bug) (fixed)
Failures calling wp.customize.Control.activate() or wp.customize.Control.deactivate()
Reported by: | westonruter | Owned by: | ocean90 |
---|---|---|---|
Milestone: | 4.1 | Priority: | normal |
Severity: | normal | Version: | 4.1 |
Component: | Customize | Keywords: | |
Focuses: | javascript | Cc: |
Description
The wp.customize.Control
class has two methods activate()
and deactivate()
which are ‘imported’ from wp.customize.Section
and wp.customize.Panel
. The activate
and deactivate
methods are just wrappers around the _toggleActive
method. This method is defined on wp.customize.Section
and wp.customize.Panel
but it was not imported into wp.customize.Control
as well, so when you attempt to call control.activate()
or control.deactivate()
you get the infamous Undefined is not a function since control._toggleActive
does not exist.
To reproduce the issue, try running this from the console:
wp.customize.control('blogname').deactivate()
The fix is simple:
-
src/wp-admin/js/customize-controls.js
913 913 */ 914 914 deactivate: Container.prototype.deactivate, 915 915 916 /** 917 * Re-use _toggleActive from Container class. 918 * 919 * @access private 920 */ 921 _toggleActive: Container.prototype._toggleActive, 922 916 923 dropdownInit: function() { 917 924 var control = this, 918 925 statuses = this.container.find('.dropdown-status'),
For interim fix if this does not make it into 4.1 is for plugins to do this:
if ( ! wp.customize.Control.prototype._toggleActive ) { wp.customize.Control.prototype._toggleActive = wp.customize.Section.prototype._toggleActive; }
Relates to the Customizer JS APIs added in #28709. Props to celloexpressions for alerting me to the issue.
Attachments (2)
Change History (19)
#1
@
10 years ago
- Keywords has-patch commit added
- Owner set to ocean90
- Status changed from new to reviewing
#2
@
10 years ago
30701.diff makes sense.
#3
@
10 years ago
In 30701.2.diff I added a lot more unit tests to improve coverage on the new models, including these activate()
/deactivate()
methods.
#5
follow-up:
↓ 6
@
10 years ago
- Keywords fixed-major added
Let's move the unit tests to a new ticket for now.
#6
in reply to:
↑ 5
@
10 years ago
Replying to ocean90:
Let's move the unit tests to a new ticket for now.
Should not unit test patches be kept on the tickets for the issues they verify?
This ticket was mentioned in Slack in #core by johnbillion. View the logs.
10 years ago
#11
@
10 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
[30919] added a failing test.
https://travis-ci.org/aaronjorbin/develop.wordpress/jobs/44355927
#12
follow-up:
↓ 14
@
10 years ago
Strange. Travis reports the error:
Error: Syntax error, unrecognized expression: unsupported pseudo: focusable
But this is valid jQuery: http://api.jqueryui.com/focusable-selector/
This ticket was mentioned in Slack in #core by ocean90. View the logs.
10 years ago
#14
in reply to:
↑ 12
@
10 years ago
Replying to westonruter:
But this is valid jQuery: http://api.jqueryui.com/focusable-selector/
jQuery UI, which trunk/tests/qunit/index.html doesn't enqeue as a dependency yet. Can't really test this, works locally.
Import missing wp.customize.Control.prototype._toggleActive