Я отлаживаю плагин Visual Composer, который сломался после того, как я обновил WordPress до 4.5, и я не могу понять, почему он вызывает ошибку TypeError.
Сообщение об ошибке в консоли:
JQMIGRATE: Migrate is installed, version 1.4.0 load-scripts.php?....
Uncaught TypeError: $template.get is not a function composer-view.js?ver=4.1.1.1:73
Единственные вхождения $template
находятся в коде ниже. Я понимаю, что это не очень много контекста, но как я могу решить эту ошибку?
/**
* Convert html into correct element
* @param html
*/
html2element: function(html) {
var attributes = {},
$template;
if (_.isString(html)) {
this.template = _.template(html);
$template = $(this.template(this.model.toJSON()).trim());
} else {
this.template = html;
$template = html;
}
_.each($template.get(0).attributes, function(attr) { // **errors on this line**
attributes[attr.name] = attr.value;
});
this.$el.attr(attributes).html($template.html());
this.setContent();
this.renderContent();
},
Обновить:
Похоже, что это может быть проблемой с jQuery. WordPress 4.5 включает в себя jQuery 1.12, в котором исправлена ошибка, позволяющая запускать определенный код с неверным синтаксисом. Я предполагаю, что код плагина должен был иметь неправильный синтаксис, но, тем не менее, работал до сих пор.
https://wordpress.org/support/topic/read-this-first-wordpress-45-master-list#post-8271654