Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@enact/core

Package Overview
Dependencies
Maintainers
1
Versions
218
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@enact/core - npm Package Compare versions

Comparing version 4.7.1 to 4.7.2

6

CHANGELOG.md

@@ -5,2 +5,8 @@ # Change Log

## [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

@@ -7,0 +13,0 @@

22

handle/handle.js

@@ -754,7 +754,7 @@ "use strict";

var forwardCustom = handle.forwardCustom = function (name, adapter) {
return handle(adaptEvent(function (ev) {
return named(adaptEvent(function (ev) {
for (var _len7 = arguments.length, args = new Array(_len7 > 1 ? _len7 - 1 : 0), _key7 = 1; _key7 < _len7; _key7++) {
args[_key7 - 1] = arguments[_key7];
}
var customEventPayload = adapter ? adapter.apply(void 0, [ev].concat(args)) : null;
var customEventPayload = adapter ? adapter.call.apply(adapter, [this, ev].concat(args)) : null;

@@ -773,3 +773,3 @@ // Handle either no adapter or a non-object return from the adapter

return customEventPayload;
}, forward(name))).named('forwardCustom');
}, forward(name)), 'forwardCustom');
};

@@ -819,4 +819,4 @@

exports.forwardCustom = forwardCustom;
var forwardCustomWithPrevent = handle.forwardCustomWithPrevent = named(function (name, adapter) {
return function (ev) {
var forwardCustomWithPrevent = handle.forwardCustomWithPrevent = function (name, adapter) {
return named(function (ev) {
for (var _len8 = arguments.length, args = new Array(_len8 > 1 ? _len8 - 1 : 0), _key8 = 1; _key8 < _len8; _key8++) {

@@ -826,4 +826,4 @@ args[_key8 - 1] = arguments[_key8];

var prevented = false;
var adapterWithPrevent = function adapterWithPrevent() {
var customEventPayload = adapter ? adapter.apply(void 0, [ev].concat(args)) : null;
function adapterWithPrevent() {
var customEventPayload = adapter ? adapter.call.apply(adapter, [this, ev].concat(args)) : null;
var existingPreventDefault = null;

@@ -847,6 +847,6 @@

return customEventPayload;
};
return forwardCustom(name, adapterWithPrevent).apply(void 0, [ev].concat(args)) && !prevented;
};
}, 'forwardCustomWithPrevent');
}
return forwardCustom.call(this, name, adapterWithPrevent.bind(this)).apply(void 0, [ev].concat(args)) && !prevented;
}, 'forwardCustomWithPrevent');
};

@@ -853,0 +853,0 @@ /**

"use strict";
var _propTypes = _interopRequireDefault(require("prop-types"));
var _react = require("react");
var _react2 = require("@testing-library/react");
var _handle = require("../handle");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
function _possibleConstructorReturn(self, call) { if (call && (typeof call === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

@@ -448,2 +463,87 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }

});
test('should support bound adapter function', function () {
var handler = jest.fn();
var expected = 'ok';
var obj = {
data: expected,
adapter: function adapter() {
return {
value: this === null || this === void 0 ? void 0 : this.data
};
}
};
var forwarderFn = (0, _handle.forwardCustom)('onCustomEvent', obj.adapter).bind(obj);
forwarderFn(null, {
onCustomEvent: handler
}, null);
var actual = handler.mock.calls[0][0];
expect(actual).toEqual(expect.objectContaining({
value: expected
}));
});
test('should support bound adapter function by call', function () {
var handler = jest.fn();
var expected = 'ok';
var obj = {
data: expected,
adapter: function adapter() {
return {
value: this === null || this === void 0 ? void 0 : this.data
};
}
};
var forwarderFn = (0, _handle.forwardCustom)('onCustomEvent', (0, _handle.call)('adapter')).bind(obj);
forwarderFn(null, {
onCustomEvent: handler
}, null);
var actual = handler.mock.calls[0][0];
expect(actual).toEqual(expect.objectContaining({
value: expected
}));
});
test('should support bound adapter function by handle', function () {
var handler = jest.fn();
var expected = 'ok';
var TestComponent = /*#__PURE__*/function (_Component) {
_inherits(TestComponent, _Component);
var _super = _createSuper(TestComponent);
function TestComponent(props) {
var _this;
_classCallCheck(this, TestComponent);
_this = _super.call(this, props);
_this.data = expected;
(0, _handle.handle)((0, _handle.forwardCustom)('onCustomEvent', (0, _handle.call)('adapter'))).bindAs(_assertThisInitialized(_this), 'handleCustomEvent');
return _this;
}
_createClass(TestComponent, [{
key: "componentDidMount",
value: function componentDidMount() {
this.handleCustomEvent(null, this.props, this.context);
}
}, {
key: "adapter",
value: function adapter() {
return {
value: this === null || this === void 0 ? void 0 : this.data
};
}
}, {
key: "render",
value: function render() {
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {});
}
}]);
return TestComponent;
}(_react.Component);
TestComponent.propTypes = {
onCustomEvent: _propTypes["default"].func
};
(0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TestComponent, {
onCustomEvent: handler
}));
var actual = handler.mock.calls[0][0];
expect(actual).toEqual(expect.objectContaining({
value: expected
}));
});
});

@@ -528,2 +628,87 @@ describe('#forwardCustomWithPrevent', function () {

});
test('should support bound adapter function', function () {
var handler = jest.fn();
var expected = 'ok';
var obj = {
data: expected,
adapter: function adapter() {
return {
value: this === null || this === void 0 ? void 0 : this.data
};
}
};
var forwarderFn = (0, _handle.forwardCustomWithPrevent)('onCustomEvent', obj.adapter).bind(obj);
forwarderFn(null, {
onCustomEvent: handler
}, null);
var actual = handler.mock.calls[0][0];
expect(actual).toEqual(expect.objectContaining({
value: expected
}));
});
test('should support bound adapter function by call', function () {
var handler = jest.fn();
var expected = 'ok';
var obj = {
data: expected,
adapter: function adapter() {
return {
value: this === null || this === void 0 ? void 0 : this.data
};
}
};
var forwarderFn = (0, _handle.forwardCustomWithPrevent)('onCustomEvent', (0, _handle.call)('adapter')).bind(obj);
forwarderFn(null, {
onCustomEvent: handler
}, null);
var actual = handler.mock.calls[0][0];
expect(actual).toEqual(expect.objectContaining({
value: expected
}));
});
test('should support bound adapter function by handle', function () {
var handler = jest.fn();
var expected = 'ok';
var TestComponent = /*#__PURE__*/function (_Component2) {
_inherits(TestComponent, _Component2);
var _super2 = _createSuper(TestComponent);
function TestComponent(props) {
var _this2;
_classCallCheck(this, TestComponent);
_this2 = _super2.call(this, props);
_this2.data = expected;
(0, _handle.handle)((0, _handle.forwardCustomWithPrevent)('onCustomEvent', (0, _handle.call)('adapter'))).bindAs(_assertThisInitialized(_this2), 'handleCustomEvent');
return _this2;
}
_createClass(TestComponent, [{
key: "componentDidMount",
value: function componentDidMount() {
this.handleCustomEvent(null, this.props, this.context);
}
}, {
key: "adapter",
value: function adapter() {
return {
value: this === null || this === void 0 ? void 0 : this.data
};
}
}, {
key: "render",
value: function render() {
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {});
}
}]);
return TestComponent;
}(_react.Component);
TestComponent.propTypes = {
onCustomEvent: _propTypes["default"].func
};
(0, _react2.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(TestComponent, {
onCustomEvent: handler
}));
var 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', function () {

@@ -530,0 +715,0 @@ var event = 'onMyClick';

{
"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.",

@@ -5,0 +5,0 @@ "repository": {

@@ -58,2 +58,10 @@ "use strict";

},
// 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

@@ -106,7 +114,2 @@ {

},
// Edge
{
platform: 'edge',
regex: /Edge\/(\d+)/
},
// iOS 3 - 5

@@ -240,2 +243,5 @@ // Apple likes to make this complicated

}
} else if (p.platform === 'edge' && m[2]) {
plat.chrome = Number(m[1]);
v = Number(m[2]);
} else {

@@ -242,0 +248,0 @@ v = Number(m[1]);

@@ -119,2 +119,68 @@ "use strict";

});
describe('parseUserAgent for Edge', function () {
var edge1 = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36 Edg/113.0.1774.42';
var edge2 = 'Mozilla/5.0 (Linux; Android 10; HD1913) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.5672.76 Mobile Safari/537.36 EdgA/113.0.1774.38';
var edge3 = 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 EdgiOS/113.1774.42 Mobile/15E148 Safari/605.1.15';
var edge4 = 'Mozilla/5.0 (Windows Mobile 10; Android 10.0; Microsoft; Lumia 950XL) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Mobile Safari/537.36 Edge/40.15254.603';
test('should return edge for Edg', function () {
var expected = {
platformName: 'edge'
};
var actual = (0, _platform.parseUserAgent)(edge1);
expect(actual).toMatchObject(expected);
expected = {
chrome: 113
};
expect(actual).toMatchObject(expected);
expected = {
edge: 113
};
expect(actual).toMatchObject(expected);
});
test('should return edge for EdgA', function () {
var expected = {
platformName: 'edge'
};
var actual = (0, _platform.parseUserAgent)(edge2);
expect(actual).toMatchObject(expected);
expected = {
chrome: 113
};
expect(actual).toMatchObject(expected);
expected = {
edge: 113
};
expect(actual).toMatchObject(expected);
});
test('should return edge for EdgiOS', function () {
var expected = {
platformName: 'edge'
};
var actual = (0, _platform.parseUserAgent)(edge3);
expect(actual).toMatchObject(expected);
expected = {
chrome: 113
};
expect(actual).not.toMatchObject(expected);
expected = {
edge: 113
};
expect(actual).toMatchObject(expected);
});
test('should return edge for Edge', function () {
var expected = {
platformName: 'edge'
};
var actual = (0, _platform.parseUserAgent)(edge4);
expect(actual).toMatchObject(expected);
expected = {
chrome: 113
};
expect(actual).toMatchObject(expected);
expected = {
edge: 40
};
expect(actual).toMatchObject(expected);
});
});
describe('parseUserAgent for User-Agent Reduction', function () {

@@ -121,0 +187,0 @@ var testVersion = '113';

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc