Skip to content

Commit

Permalink
4.7.2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
enact-bot committed Jul 14, 2023
2 parents 3be75a8 + 46fd821 commit f8df363
Show file tree
Hide file tree
Showing 28 changed files with 82,517 additions and 224,286 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ The following is a curated list of changes in the Enact project, newest changes
### Fixed

- `ui/Scroller` and `ui/VirtualList` to pass scrolling state properly to UI libraries
## [4.7.2] - 2023-07-14

### Fixed

- `core/handle.forwardCustom` and `core/handle.forwardCustomWithPrevent` to bind an adapter function properly
- `spotlight` to not show the focus effect when pointer mode is changed to `false` by touch while an app is loading

## [4.7.1] - 2023-06-02

Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"lerna": "4.0.0",
"version": "4.7.1",
"version": "4.7.2",
"command": {
"bootstrap": {
"ci": false,
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "enact",
"version": "4.7.1",
"version": "4.7.2",
"description": "Monorepo for all Enact front end libraries.",
"private": true,
"scripts": {
Expand Down
5 changes: 5 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ The following is a curated list of changes in the Enact core module, newest chan
## [4.5.4] - 2023-06-07

No significant changes.
## [4.7.2] - 2023-07-14

### Fixed

- `core/handle.forwardCustom` and `core/handle.forwardCustomWithPrevent` to bind an adapter function properly

## [4.7.1] - 2023-06-02

Expand Down
28 changes: 14 additions & 14 deletions packages/core/handle/handle.js
Original file line number Diff line number Diff line change
Expand Up @@ -730,10 +730,10 @@ const adaptEvent = handle.adaptEvent = curry(function (adapter, handler) {
* @memberof core/handle
* @public
*/
const forwardCustom = handle.forwardCustom = (name, adapter) => handle(
adaptEvent(
(ev, ...args) => {
let customEventPayload = adapter ? adapter(ev, ...args) : null;
const forwardCustom = handle.forwardCustom = function (name, adapter) {
return named(adaptEvent(
function (ev, ...args) {
let customEventPayload = adapter ? adapter.call(this, ev, ...args) : null;

// Handle either no adapter or a non-object return from the adapter
if (!customEventPayload || typeof customEventPayload !== 'object') {
Expand All @@ -751,8 +751,8 @@ const forwardCustom = handle.forwardCustom = (name, adapter) => handle(
return customEventPayload;
},
forward(name)
)
).named('forwardCustom');
), 'forwardCustom');
};

/**
* Creates a handler that will forward the event to a function at `name` on `props` with capability
Expand Down Expand Up @@ -795,12 +795,12 @@ const forwardCustom = handle.forwardCustom = (name, adapter) => handle(
* @memberof core/handle
* @private
*/
const forwardCustomWithPrevent = handle.forwardCustomWithPrevent = named((name, adapter) => {
return (ev, ...args) => {
const forwardCustomWithPrevent = handle.forwardCustomWithPrevent = function (name, adapter) {
return named(function (ev, ...args) {
let prevented = false;

const adapterWithPrevent = () => {
let customEventPayload = adapter ? adapter(ev, ...args) : null;
function adapterWithPrevent () {
let customEventPayload = adapter ? adapter.call(this, ev, ...args) : null;
let existingPreventDefault = null;

// Handle either no adapter or a non-object return from the adapter
Expand All @@ -822,11 +822,11 @@ const forwardCustomWithPrevent = handle.forwardCustomWithPrevent = named((name,
};

return customEventPayload;
};
}

return forwardCustom(name, adapterWithPrevent)(ev, ...args) && !prevented;
};
}, 'forwardCustomWithPrevent');
return forwardCustom.call(this, name, adapterWithPrevent.bind(this))(ev, ...args) && !prevented;
}, 'forwardCustomWithPrevent');
};

/**
* Accepts a handler and returns the logical complement of the value returned from the handler.
Expand Down
172 changes: 172 additions & 0 deletions packages/core/handle/tests/handle-specs.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import PropTypes from 'prop-types';
import {Component} from 'react';
import {render} from '@testing-library/react';

import {
adaptEvent,
call,
Expand Down Expand Up @@ -567,6 +571,90 @@ describe('handle', () => {

expect(actual).toEqual(expected);
});

test('should support bound adapter function', () => {
const handler = jest.fn();
const expected = 'ok';
const obj = {
data: expected,
adapter: function () {
return {
value: this?.data
};
}
};
const forwarderFn = forwardCustom('onCustomEvent', obj.adapter).bind(obj);
forwarderFn(null, {onCustomEvent: handler}, null);

const actual = handler.mock.calls[0][0];

expect(actual).toEqual(expect.objectContaining({
value: expected
}));
});

test('should support bound adapter function by call', () => {
const handler = jest.fn();
const expected = 'ok';
const obj = {
data: expected,
adapter: function () {
return {
value: this?.data
};
}
};

const forwarderFn = forwardCustom('onCustomEvent', call('adapter')).bind(obj);
forwarderFn(null, {onCustomEvent: handler}, null);

const actual = handler.mock.calls[0][0];

expect(actual).toEqual(expect.objectContaining({
value: expected
}));
});

test('should support bound adapter function by handle', () => {
const handler = jest.fn();
const expected = 'ok';

class TestComponent extends Component {
static propTypes = {
onCustomEvent: PropTypes.func
};

constructor (props) {
super(props);

this.data = expected;
handle(
forwardCustom('onCustomEvent', call('adapter'))
).bindAs(this, 'handleCustomEvent');
}

componentDidMount () {
this.handleCustomEvent(null, this.props, this.context);
}

adapter () {
return {
value: this?.data
};
}

render () {
return <div />;
}
}
render(<TestComponent onCustomEvent={handler} />);

const actual = handler.mock.calls[0][0];

expect(actual).toEqual(expect.objectContaining({
value: expected
}));
});
});

describe('#forwardCustomWithPrevent', () => {
Expand Down Expand Up @@ -647,6 +735,90 @@ describe('handle', () => {
expect(actual).toEqual(expected);
});

test('should support bound adapter function', () => {
const handler = jest.fn();
const expected = 'ok';
const obj = {
data: expected,
adapter: function () {
return {
value: this?.data
};
}
};
const forwarderFn = forwardCustomWithPrevent('onCustomEvent', obj.adapter).bind(obj);
forwarderFn(null, {onCustomEvent: handler}, null);

const actual = handler.mock.calls[0][0];

expect(actual).toEqual(expect.objectContaining({
value: expected
}));
});

test('should support bound adapter function by call', () => {
const handler = jest.fn();
const expected = 'ok';
const obj = {
data: expected,
adapter: function () {
return {
value: this?.data
};
}
};

const forwarderFn = forwardCustomWithPrevent('onCustomEvent', call('adapter')).bind(obj);
forwarderFn(null, {onCustomEvent: handler}, null);

const actual = handler.mock.calls[0][0];

expect(actual).toEqual(expect.objectContaining({
value: expected
}));
});

test('should support bound adapter function by handle', () => {
const handler = jest.fn();
const expected = 'ok';

class TestComponent extends Component {
static propTypes = {
onCustomEvent: PropTypes.func
};

constructor (props) {
super(props);

this.data = expected;
handle(
forwardCustomWithPrevent('onCustomEvent', call('adapter'))
).bindAs(this, 'handleCustomEvent');
}

componentDidMount () {
this.handleCustomEvent(null, this.props, this.context);
}

adapter () {
return {
value: this?.data
};
}

render () {
return <div />;
}
}
render(<TestComponent onCustomEvent={handler} />);

const actual = handler.mock.calls[0][0];

expect(actual).toEqual(expect.objectContaining({
value: expected
}));
});

test('should call the next handler when `preventDefault` from provided props hasn\'t been called', () => {
const event = 'onMyClick';
const handler = jest.fn();
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@enact/core",
"version": "4.7.1",
"version": "4.7.2",
"description": "Enact is an open source JavaScript framework containing everything you need to create a fast, scalable mobile or web application.",
"repository": {
"type": "git",
Expand Down
9 changes: 7 additions & 2 deletions packages/core/platform/platform.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ const webOSVersion = {
const platforms = [
// Windows Phone 7 - 10
{platform: 'windowsPhone', regex: /Windows Phone (?:OS )?(\d+)[.\d]+/},
// Edge
{platform: 'edge', regex: /Chrome\/(\d+)[.\d]+.*Edg(?:e|A|iOS)?\/(\d+)[.\d]+/},
{platform: 'edge', regex: /Edg(?:e|A|iOS)?\/(\d+)[.\d]+/},
// Android 4+ using Chrome
{platform: 'androidChrome', regex: /Android .* Chrome\/(\d+)[.\d]+/},
// Android 2 - 4
Expand All @@ -67,8 +70,6 @@ const platforms = [
{platform: 'ie', regex: /MSIE (\d+)/},
// IE 11
{platform: 'ie', regex: /Trident\/.*; rv:(\d+)/},
// Edge
{platform: 'edge', regex: /Edge\/(\d+)/},
// iOS 3 - 5
// Apple likes to make this complicated
{platform: 'ios', regex: /iP(?:hone|ad;(?: U;)? CPU) OS (\d+)/},
Expand Down Expand Up @@ -132,6 +133,9 @@ const parseUserAgent = (userAgent) => {
if (v >= 7 || v === -1) {
plat.chrome = Number(m[1]);
}
} else if (p.platform === 'edge' && m[2]) {
plat.chrome = Number(m[1]);
v = Number(m[2]);
} else {
v = Number(m[1]);
}
Expand All @@ -143,6 +147,7 @@ const parseUserAgent = (userAgent) => {
};
}
plat.platformName = p.platform;

break;
}
}
Expand Down
Loading

0 comments on commit f8df363

Please sign in to comment.