MT#63401 jquery upgrade: restore .attr( behaviour

repeatable section selectors fail to recognize the selected ceckbox,
because .attr() is used, but newer jquery would need .prop().

the compat layer is extended to restore .attr() behaviour.

Change-Id: I2dc23cb4dd120080cd6d9aa9d3902ed7285c977b
(cherry picked from commit 9752c6c290)
mr14.0
Rene Krenn 2 months ago
parent 661e8c6410
commit 7e057d7b2a

@ -20,13 +20,48 @@ if ( matched.browser ) {
jQuery.browser.version = matched.version;
}
(function($) {
var $old = $;
window.$ = window.jQuery = function(selector, context) {
if (selector === '#' || selector === '') {
console.warn('jquery # override');
return $old([]);
(function ($) {
const booleanAttrs = {
checked: true,
selected: true,
disabled: true,
readonly: true,
multiple: true
};
var oldInit = $.fn.init;
$.fn.init = function (selector, context, root) {
if (typeof selector === 'string') {
if (selector === '#' || selector.trim() === '') {
console.warn('jquery # override', new Error().stack);
return oldInit.call(this, [], context, root);
}
}
return oldInit.call(this, selector, context, root);
};
$.fn.init.prototype = $.fn;
const oldAttr = $.fn.attr;
$.fn.attr = function (name, value) {
if (booleanAttrs[name]) {
// getter
if (value === undefined) {
return this.prop(name) ? name : undefined;
}
// setter
return this.prop(name, !!value);
}
return $old(selector, context);
return oldAttr.apply(this, arguments);
};
})(jQuery);
Loading…
Cancel
Save