Only load vendored jQuery on NC34+, verified against NC32/33/34 in testbak/

Core still provides a working jQuery on NC32/33, but via a read-only
window.$ getter - loading our own vendored copy there too made its UMD
wrapper throw trying to reassign window.$ (confirmed on real containers,
harmless in practice since this app attaches via window.jQuery, but a real
avoidable console exception). Gate the extra script() call on
ServerVersion::getMajorVersion() >= 34 instead.

Re-tested both sides of the boundary: NC32 no longer requests jquery.js and
has zero console errors; NC34 still requests it and still works.
This commit is contained in:
2026-09-27 00:24:47 +02:00
parent 35e1f5df32
commit a607426a9c
3 changed files with 16 additions and 6 deletions
+11 -2
View File
@@ -2,8 +2,17 @@
// Nextcloud's global jQuery has been deprecated since NC19 and is no longer
// reliably present on NC34+ (see e.g. serverinfo needing to bundle its own) -
// term.js (jquery.terminal) and index.js both require jQuery to be loaded
// first, so ship and load our own copy rather than relying on core.
script('extended_occweb', 'jquery');
// first, so ship and load our own copy where core no longer provides one.
//
// Only do this on NC34+: on NC32/33 core still exposes a working jQuery, but
// via a read-only `window.$` getter - loading our vendored copy there too
// makes its UMD wrapper throw trying to reassign `window.$` (confirmed via
// testbak/, see the README compat matrix). Harmless in practice (this app
// attaches via window.jQuery, not window.$) but a real, avoidable console
// exception, so skip the extra load where core's own jQuery already works.
if (\OCP\Server::get(\OCP\ServerVersion::class)->getMajorVersion() >= 34) {
script('extended_occweb', 'jquery');
}
script('extended_occweb', 'index');
script('extended_occweb', 'term');
script('extended_occweb', 'unix_formatting');