@enact/core 4.9.0 → 4.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/package.json +1 -1
- package/platform/platform.js +7 -12
- package/util/tests/util-specs.js +23 -0
- package/util/util.d.ts +4 -0
- package/util/util.js +24 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
The following is a curated list of changes in the Enact core module, newest changes on the top.
|
|
4
4
|
|
|
5
|
+
## [4.9.2] - 2024-09-26
|
|
6
|
+
|
|
7
|
+
No significant changes.
|
|
8
|
+
|
|
9
|
+
## [4.9.1] - 2024-09-09
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- `core/util` function `setDefaultProps` to set props that are missing or `undefined` to default values
|
|
14
|
+
|
|
5
15
|
## [4.9.0] - 2024-07-17
|
|
6
16
|
|
|
7
17
|
No significant changes.
|
package/package.json
CHANGED
package/platform/platform.js
CHANGED
|
@@ -268,18 +268,6 @@ var parseUserAgentLegacy = function parseUserAgentLegacy(userAgent) {
|
|
|
268
268
|
break;
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
|
-
if ('webos' === plat.platformName) {
|
|
272
|
-
(0, _deprecate["default"])({
|
|
273
|
-
name: plat.platformName,
|
|
274
|
-
message: 'Refer `@enact/webos`\'s `platform` for webOS specific information.',
|
|
275
|
-
until: '5.0.0'
|
|
276
|
-
});
|
|
277
|
-
} else if (!['chrome', 'safari', 'firefox'].includes(plat.platformName)) {
|
|
278
|
-
(0, _deprecate["default"])({
|
|
279
|
-
name: plat.platformName,
|
|
280
|
-
until: '5.0.0'
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
271
|
return plat;
|
|
284
272
|
};
|
|
285
273
|
|
|
@@ -468,6 +456,13 @@ var platform = exports.platform = {};
|
|
|
468
456
|
replacedBy: 'touchScreen'
|
|
469
457
|
});
|
|
470
458
|
}
|
|
459
|
+
if (name === 'webos') {
|
|
460
|
+
(0, _deprecate["default"])({
|
|
461
|
+
name: name,
|
|
462
|
+
message: 'Refer `@enact/webos`\'s `platform` for webOS specific information.',
|
|
463
|
+
until: '5.0.0'
|
|
464
|
+
});
|
|
465
|
+
}
|
|
471
466
|
var p = detect();
|
|
472
467
|
return p[name];
|
|
473
468
|
}
|
package/util/tests/util-specs.js
CHANGED
|
@@ -212,6 +212,29 @@ describe('util', function () {
|
|
|
212
212
|
expect(expected).toEqual(actual);
|
|
213
213
|
});
|
|
214
214
|
});
|
|
215
|
+
describe('setDefaultProps', function () {
|
|
216
|
+
var props = {
|
|
217
|
+
// eslint-disable-next-line no-undefined
|
|
218
|
+
direction: undefined,
|
|
219
|
+
index: 0,
|
|
220
|
+
size: 'small'
|
|
221
|
+
};
|
|
222
|
+
var defaultProps = {
|
|
223
|
+
direction: 'below',
|
|
224
|
+
selected: true,
|
|
225
|
+
size: 'large'
|
|
226
|
+
};
|
|
227
|
+
test('should set props that are missing or `undefined` to default values', function () {
|
|
228
|
+
var expected = {
|
|
229
|
+
direction: 'below',
|
|
230
|
+
index: 0,
|
|
231
|
+
selected: true,
|
|
232
|
+
size: 'small'
|
|
233
|
+
};
|
|
234
|
+
var actual = (0, _util.setDefaultProps)(props, defaultProps);
|
|
235
|
+
expect(expected).toEqual(actual);
|
|
236
|
+
});
|
|
237
|
+
});
|
|
215
238
|
describe('shallowEqual', function () {
|
|
216
239
|
var child = {
|
|
217
240
|
name: 'child'
|
package/util/util.d.ts
CHANGED
|
@@ -154,6 +154,10 @@ export function mapAndFilterChildren(
|
|
|
154
154
|
callback: Function,
|
|
155
155
|
filter?: Function,
|
|
156
156
|
): any;
|
|
157
|
+
/**
|
|
158
|
+
* Sets props that are missing or `undefined` to default values
|
|
159
|
+
*/
|
|
160
|
+
export function setDefaultProps(props: Obejct, defaultProps: Obejct): object;
|
|
157
161
|
/**
|
|
158
162
|
* Performs shallow comparison for given objects.
|
|
159
163
|
*/
|
package/util/util.js
CHANGED
|
@@ -9,7 +9,7 @@ Object.defineProperty(exports, "Job", {
|
|
|
9
9
|
return _Job["default"];
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
exports.shallowEqual = exports.perfNow = exports.mergeClassNameMaps = exports.memoize = exports.mapAndFilterChildren = exports.isRenderable = exports.extractAriaProps = exports.coerceFunction = exports.coerceArray = exports.clamp = exports.cap = void 0;
|
|
12
|
+
exports.shallowEqual = exports.setDefaultProps = exports.perfNow = exports.mergeClassNameMaps = exports.memoize = exports.mapAndFilterChildren = exports.isRenderable = exports.extractAriaProps = exports.coerceFunction = exports.coerceArray = exports.clamp = exports.cap = void 0;
|
|
13
13
|
var _always = _interopRequireDefault(require("ramda/src/always"));
|
|
14
14
|
var _is = _interopRequireDefault(require("ramda/src/is"));
|
|
15
15
|
var _unless = _interopRequireDefault(require("ramda/src/unless"));
|
|
@@ -280,6 +280,29 @@ var mapAndFilterChildren = exports.mapAndFilterChildren = function mapAndFilterC
|
|
|
280
280
|
}
|
|
281
281
|
};
|
|
282
282
|
|
|
283
|
+
/**
|
|
284
|
+
* Sets props that are missing or `undefined` to default values
|
|
285
|
+
*
|
|
286
|
+
* @function
|
|
287
|
+
* @param {Obejct} props Props object
|
|
288
|
+
* @param {Obejct} defaultProps Default value object
|
|
289
|
+
*
|
|
290
|
+
* @returns {Object} Props with default values
|
|
291
|
+
* @memberof core/util
|
|
292
|
+
* @public
|
|
293
|
+
*/
|
|
294
|
+
var setDefaultProps = exports.setDefaultProps = function setDefaultProps(props) {
|
|
295
|
+
var defaultProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
296
|
+
var result = Object.assign({}, props);
|
|
297
|
+
for (var prop in defaultProps) {
|
|
298
|
+
// eslint-disable-next-line no-undefined
|
|
299
|
+
if (props[prop] === undefined) {
|
|
300
|
+
result[prop] = defaultProps[prop];
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return result;
|
|
304
|
+
};
|
|
305
|
+
|
|
283
306
|
/**
|
|
284
307
|
* Performs shallow comparison for given objects.
|
|
285
308
|
*
|