With SAPUI5 1.82, the third-party library jQuery is upgraded from jQuery 2.2.3 to jQuery 3.5.1. Several measures have been implemented to make this new framework variant of jQuery as compatible to the previously contained version as feasible. In particular, we introduce a compatibility layer to ensure that most of your existing application or control code may not need adjustment. This could, however, introduce incompatibilites to the new jQuery version. Please read the following information carefully to understand any current and possible future impact.
With the major version upgrade from jQuery 2.x to jQuery 3.x, a number of incompatible changes have been introduced (see the breaking changes in the jQuery 3.0 Core Upgrade Guide).
We evaluated each of those changes and classified them to see what needed to be fixed on the layers of framework, control and application. To minimize the migration effort required by application and control developers, we have introduced an additional compatibility layer on top of jQuery (delivered as sap/ui/thirdparty/jquery-compat.js).
This compatibility layer has the following properties:
-
It can be excluded by setting the
excludeJQueryCompatconfiguration via:-
URL parameter (case-sensitive):
sap-ui-excludeJQueryCompat=true -
Data attribute of the SAPUI5 bootstrap (case-insensitive):
data-sap-ui-excludejquerycompat="true" -
Global configuration object before SAPUI5 boots up (case-sensitive):
window["sap-ui-config"]["excludejQueryCompat"]=true
-
-
It restores several APIs that have been incompatibly changed in jQuery 3.x back to their old behavior in jQuery 2.x. Details on those changes can be found in the table below.
The following table contains some important differences between jQuery 2.2.3 and jQuery 3.5.1. The rightmost column indicates whether such an incompatible change of jQuery 3.x was "rolled back" to the original jQuery 2.x behavior by our compatibility layer.
Though we aim to make sure that the jQuery APIs used by controls and applications stay compatible even after breaking changes by jQuery, we cannot guarantee a 100% compatibility rate.
|
API (and what has changed) |
jQuery 2.x |
jQuery 3.x |
jQuery 3.x + Compat. Layer = jQuery 2.x |
|---|---|---|---|
|
|
function exists |
removed |
|
|
must have at least one valid DOM element, otherwise it throws an error |
doesn't throw error |
throws an error |
|
|
when a jQuery object is created from a node (like in our |
|
|
|
|
function was removed; jQuery proposes to use |
exists |
removed |
|
|
return value type changed |
returns integer |
returns float |
|
|
in case of an empty jQuery element, the return value was changed from |
returns |
returns |
|
|
|
exist |
removed |
|
|
|
Function |
Function |
|
|
|
|
|
Some incompatible changes that are introduced with jQuery 3.5.1 aren't restored to the old behavior of jQuery 2.2.3 by our compatibility layer. This is because we consider them reasonable improvements, for which we don't see any negative impact from our evaluation with existing applications.
|
API |
jQuery 2.x |
jQuery 3.x |
|---|---|---|
|
doesn't include the scrollbar width if there is one |
includes the width or height of the scrollbar, if there is one |
doesn't include the scrollbar width if there is one Use |
|
|
uses |
uses |
|
for multiple response header values that have the same header name |
only returns the first header value |
merges multiple header values into a string, separated by ", " |
|
callback is delayed even if the |
Function |
Function |
|
|
exists |
removed, because it's an undocumented internal method! |
|
in case the key contains a dash "-" |
||
|
unreliable pseudo-selector has been removed |
concatenates the selector property after further tree traversal calls, for example |
according to jQuery documentation, it was never reliable and thus removed with 3.0: https://api.jquery.com/selector/ |
|
see https://jquery.com/upgrade-guide/3.0/#deprecated-additional-easing-function-parameters |
function accepts multiple arguments |
function accepts only one argument |
|
see also the table below |
automatically add a |
adding elements to a table does not create an additional |
|
see also the table below |
some jQuery APIs in certain contexts call the |
the |
Due to the above-mentioned jQuery incompatibilities, SAPUI5 behaves differently in certain cases after the jQuery update.
The following table describes these behavior changes and gives recommendations how to handle them:
|
Changed Behavior |
in SAPUI5 < 1.82 |
in SAPUI5 >= 1.82 |
Recommendation |
|---|---|---|---|
|
Automatic creation of see also the table above |
SAPUI5 Controls using a string-based rendering approach in their renderer modules implicitly use jQuery APIs to create the DOM elements. Whenever you flush a |
flushing a |
If your application or control code depends on a Adding the |
|
Self-Closing HTML Tags see also the table above |
SAPUI5 uses a UI5-specific jQuery 2.2.3 variant. Formerly, its internal Since jQuery 3.5.0, this replacement is no longer done. Instead, the browser will automatically close the self-closing HTML element based on the DOM hierarchy, which could very likely occur at the wrong place. The custom jQuery 2.2.3 variant used in SAPUI5 also implements this change, because self-closing HTML tags for non-void HTML elements are not valid in HTML5. The updated jQuery 2.2.3 variant is contained in the following SAPUI5 versions:
|
jQuery no longer closes self-closing tags for non-void HTML elements in the |
You should properly close non-void HTML elements. For detailed instructions for identifying affected code and fixing it, see SAP Note 2944336. Properly closing non-void HTML elements in this way is backward-compatible to older SAPUI5 and jQuery versions. |
At the time of writing, the following jQuery issues have been identified. They have been fixed in the jQuery variant sap/ui/thirdparty/jquery.js shipped with SAPUI5 1.82 and later:
-
jQuery Issue #4382: Bug with focus() method in a specific case in 3.4.0.
Introduced with jQuery 3.4.0, this causes several tests to fail.
The bug isn't fixed in the jQuery 3.x code line, but only in the main branch for an upcoming jQuery 4.x release (see this commit).
At the time of writing, it's not clear whether and when the fix will be downported to the jQuery 3.x code line.
-
jQuery Issue #4417: Exception when element is removed on blur.
At the time of writing, the bug is still open in jQuery's Github repository. Once the bug has been fixed, the in-place patch in our framework's jQuery variant will be deleted.
-
jQuery Issue #4431: Position() calculated incorrectly for elements inside a table.
jQuery wrongly calculates the offsetParent. The
offsetParentproperty ofHTMLElementreturns a<td>,<th>,<table>ancestor even when the ancestor element has astaticCSS position.The original implementation of
jQuery.fn.offsetParentcan handle this case correctly.
You can activate an additional support rule with the UI5 Support Assistant. The rule "Usage of deprecated jQuery API" will show you warnings for all instances of deprecated jQuery 3.x API usage.
Though these APIs are "only" deprecated and could still be used, the jQuery project will remove them with their next version jQuery 4.x
To stay future-proof, we strongly recommend that you remove/refactor all your application and control code so as not to use any deprecated jQuery API anymore.
