jsx-native-events
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -5,2 +5,11 @@ # Changelog | ||
### [1.0.2](https://github.com/calebdwilliams/jsx-native-events/compare/v1.0.1...v1.0.2) (2019-08-02) | ||
### Bug Fixes | ||
* **ref:** :bug: fix ignoring existing ref prop ([bbab5e6](https://github.com/calebdwilliams/jsx-native-events/commit/bbab5e6)) | ||
### [1.0.1](https://github.com/calebdwilliams/jsx-native-events/compare/v0.1.0...v1.0.1) (2019-06-17) | ||
@@ -7,0 +16,0 @@ |
@@ -0,1 +1,3 @@ | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
@@ -23,2 +25,11 @@ | ||
newProps.ref = function (element) { | ||
// merge existing ref prop | ||
if (props && props.ref) { | ||
if (typeof props.ref === 'function') { | ||
props.ref(element); | ||
} else if (_typeof(props.ref) === 'object') { | ||
props.ref.current = element; | ||
} | ||
} | ||
if (element) { | ||
@@ -29,3 +40,3 @@ if (props) { | ||
keys.filter(function (key) { | ||
return key.match(/^onEvent/); | ||
return key.match(eventPattern); | ||
}).map(function (key) { | ||
@@ -32,0 +43,0 @@ return { |
@@ -5,2 +5,4 @@ 'use strict'; | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
@@ -34,2 +36,11 @@ | ||
newProps.ref = function (element) { | ||
// merge existing ref prop | ||
if (props && props.ref) { | ||
if (typeof props.ref === 'function') { | ||
props.ref(element); | ||
} else if (_typeof(props.ref) === 'object') { | ||
props.ref.current = element; | ||
} | ||
} | ||
if (element) { | ||
@@ -40,3 +51,3 @@ if (props) { | ||
keys.filter(function (key) { | ||
return key.match(/^onEvent/); | ||
return key.match(eventPattern); | ||
}).map(function (key) { | ||
@@ -43,0 +54,0 @@ return { |
{ | ||
"name": "jsx-native-events", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Add native event handling to React's JSX to support custom event types", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -29,2 +29,4 @@ # jsx-native-events | ||
Or add `pragma: "nativeEvents"` to your [`@babel/preset-react`](https://babeljs.io/docs/en/babel-preset-react) or [`@babel/plugin-transform-react-jsx`](https://babeljs.io/docs/en/babel-plugin-transform-react-jsx) babel config. | ||
```jsx | ||
@@ -31,0 +33,0 @@ /** @jsx nativeEvents */ |
/*! | ||
* jsx-native-events v1.0.1 | ||
* jsx-native-events v1.0.2 | ||
* MIT Licensed | ||
@@ -123,2 +123,4 @@ */ | ||
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__); | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; | ||
@@ -146,2 +148,11 @@ | ||
newProps.ref = function (element) { | ||
// merge existing ref prop | ||
if (props && props.ref) { | ||
if (typeof props.ref === 'function') { | ||
props.ref(element); | ||
} else if (_typeof(props.ref) === 'object') { | ||
props.ref.current = element; | ||
} | ||
} | ||
if (element) { | ||
@@ -152,3 +163,3 @@ if (props) { | ||
keys.filter(function (key) { | ||
return key.match(/^onEvent/); | ||
return key.match(eventPattern); | ||
}).map(function (key) { | ||
@@ -155,0 +166,0 @@ return { |
/*! | ||
* jsx-native-events v1.0.1 | ||
* jsx-native-events v1.0.2 | ||
* MIT Licensed | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.JSX_CUSTOM_ELEMENTS=t(require("react")):e.JSX_CUSTOM_ELEMENTS=t(e.React)}(window,function(e){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(t,n){t.exports=e},function(e,t,n){e.exports=n(2)},function(e,t,n){"use strict";n.r(t),n.d(t,"default",function(){return f});var r=n(0),o=n.n(r),u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},a=function(e){return e.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase()},c=Symbol("jsx-native-events/event-listeners");function f(e,t){var n=u({},t);"string"==typeof e&&(n.ref=function(e){e&&(t&&Object.keys(t).filter(function(e){return e.match(/^onEvent/)}).map(function(e){return{key:e,eventName:a(e.replace("onEvent","")).replace("-","")}}).map(function(n){var r=n.eventName,o=n.key;e[c]||(e[c]=new Map),e[c].has(r)||(e.addEventListener(r,t[o]),e[c].set(r,t[o]))}))});for(var r=arguments.length,f=Array(r>2?r-2:0),i=2;i<r;i++)f[i-2]=arguments[i];return o.a.createElement.apply(null,[e,n].concat(f))}}]).default}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define(["react"],t):"object"==typeof exports?exports.JSX_CUSTOM_ELEMENTS=t(require("react")):e.JSX_CUSTOM_ELEMENTS=t(e.React)}(window,function(e){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(t,n){t.exports=e},function(e,t,n){e.exports=n(2)},function(e,t,n){"use strict";n.r(t),n.d(t,"default",function(){return l});var r=n(0),o=n.n(r),u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c=function(e){return e.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase()},i=Symbol("jsx-native-events/event-listeners"),a=/^onEvent/;function l(e,t){var n=f({},t);"string"==typeof e&&(n.ref=function(e){(t&&t.ref&&("function"==typeof t.ref?t.ref(e):"object"===u(t.ref)&&(t.ref.current=e)),e)&&(t&&Object.keys(t).filter(function(e){return e.match(a)}).map(function(e){return{key:e,eventName:c(e.replace("onEvent","")).replace("-","")}}).map(function(n){var r=n.eventName,o=n.key;e[i]||(e[i]=new Map),e[i].has(r)||(e.addEventListener(r,t[o]),e[i].set(r,t[o]))}))});for(var r=arguments.length,l=Array(r>2?r-2:0),p=2;p<r;p++)l[p-2]=arguments[p];return o.a.createElement.apply(null,[e,n].concat(l))}}]).default}); | ||
//# sourceMappingURL=jsx-native-events.min.js.map |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33757
315
61