Skip to content

Commit 94f7711

Browse files
authored
Merge pull request #3943 from dpalou/MOBILE-4508
MOBILE-4508 h5p: Update H5P lib to 1.26
2 parents 76da08b + 8021e7e commit 94f7711

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

src/core/features/h5p/assets/js/h5p.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2168,6 +2168,35 @@ H5P.trim = function (value) {
21682168
// So should we make this function deprecated?
21692169
};
21702170

2171+
/**
2172+
* Recursive function that detects deep empty structures.
2173+
*
2174+
* @param {*} value
2175+
* @returns {bool}
2176+
*/
2177+
H5P.isEmpty = value => {
2178+
if (!value && value !== 0 && value !== false) {
2179+
return true; // undefined, null, NaN and empty strings.
2180+
}
2181+
else if (Array.isArray(value)) {
2182+
for (let i = 0; i < value.length; i++) {
2183+
if (!H5P.isEmpty(value[i])) {
2184+
return false; // Array contains a non-empty value
2185+
}
2186+
}
2187+
return true; // Empty array
2188+
}
2189+
else if (typeof value === 'object') {
2190+
for (let prop in value) {
2191+
if (value.hasOwnProperty(prop) && !H5P.isEmpty(value[prop])) {
2192+
return false; // Object contains a non-empty value
2193+
}
2194+
}
2195+
return true; // Empty object
2196+
}
2197+
return false;
2198+
};
2199+
21712200
/**
21722201
* Check if JavaScript path/key is loaded.
21732202
*

src/core/features/h5p/classes/core.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ import { CorePath } from '@singletons/path';
3131
*/
3232
export class CoreH5PCore {
3333

34+
static readonly API_VERSION = {
35+
majorVersion: 1,
36+
minorVersion: 26,
37+
};
38+
3439
static readonly STYLES = [
3540
'styles/h5p.css',
3641
'styles/h5p-confirmation-dialog.css',

0 commit comments

Comments
 (0)