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)
(cherry picked from commit fbabd6eb32)
mr12.5.1
Rene Krenn 2 months ago
parent 8ae2c30cd8
commit 21ed83454c

@ -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