From fbabd6eb3221bd3be64b0bf56c251e546e7b7e8e Mon Sep 17 00:00:00 2001 From: Rene Krenn Date: Thu, 5 Mar 2026 20:06:20 +0100 Subject: [PATCH] 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 9752c6c2903107063a99450cd0a8d19943248729) --- share/static/js/libs/jquery-compat.js | 49 +++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 7 deletions(-) diff --git a/share/static/js/libs/jquery-compat.js b/share/static/js/libs/jquery-compat.js index a191d0210b..d22f144746 100644 --- a/share/static/js/libs/jquery-compat.js +++ b/share/static/js/libs/jquery-compat.js @@ -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); \ No newline at end of file