jsx-ast-utils
Advanced tools
Comparing version 1.3.5 to 1.4.0
@@ -0,1 +1,6 @@ | ||
1.4.0 / 2017-02-02 | ||
================== | ||
- [new] Add eventHandlers and eventHandlersByType to API. These are the event names for DOM elements on JSX-using libraries such as React, inferno, and preact. | ||
1.3.5 / 2016-12-14 | ||
@@ -2,0 +7,0 @@ ================== |
@@ -28,6 +28,5 @@ 'use strict'; | ||
var nodeProp = void 0; | ||
var propToFind = options.ignoreCase ? prop.toUpperCase() : prop; | ||
var hasProp = props.some(function (attribute) { | ||
return props.find(function (attribute) { | ||
// If the props contain a spread prop, then skip. | ||
@@ -40,11 +39,4 @@ if (attribute.type === 'JSXSpreadAttribute') { | ||
if (propToFind === currentProp) { | ||
nodeProp = attribute; | ||
return true; | ||
} | ||
return false; | ||
return propToFind === currentProp; | ||
}); | ||
return hasProp ? nodeProp : undefined; | ||
} |
@@ -11,2 +11,6 @@ 'use strict'; | ||
var _eventHandlers = require('./eventHandlers'); | ||
var _eventHandlers2 = _interopRequireDefault(_eventHandlers); | ||
var _getProp = require('./getProp'); | ||
@@ -31,2 +35,4 @@ | ||
elementType: _elementType2.default, | ||
eventHandlers: _eventHandlers2.default, | ||
eventHandlersByType: _eventHandlers.eventHandlersByType, | ||
getProp: _getProp2.default, | ||
@@ -33,0 +39,0 @@ getPropValue: _getPropValue2.default, |
{ | ||
"name": "jsx-ast-utils", | ||
"version": "1.3.5", | ||
"version": "1.4.0", | ||
"description": "AST utility module for statically analyzing JSX", | ||
@@ -17,6 +17,7 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"acorn-jsx": "^3.0.1", | ||
"babel-cli": "^6.14.0", | ||
"babel-core": "^6.14.0", | ||
"babel-eslint": "^7.0.0", | ||
"babel-jest": "^17.0.2", | ||
"babel-jest": "^18.0.0", | ||
"babel-polyfill": "^6.16.0", | ||
@@ -28,3 +29,3 @@ "babel-preset-es2015": "^6.14.0", | ||
"eslint-plugin-import": "^2.2.0", | ||
"jest": "^17.0.2", | ||
"jest": "^18.1.0", | ||
"rimraf": "^2.5.2" | ||
@@ -48,3 +49,2 @@ }, | ||
"dependencies": { | ||
"acorn-jsx": "^3.0.1", | ||
"object-assign": "^4.1.0" | ||
@@ -51,0 +51,0 @@ }, |
108
README.md
@@ -172,1 +172,109 @@ <p align="center"> | ||
Object - The JSXAttribute collected by AST parser. | ||
### eventHandlers | ||
```js | ||
console.log(eventHandlers); | ||
/* | ||
[ | ||
'onCopy', | ||
'onCut', | ||
'onPaste', | ||
'onCompositionEnd', | ||
'onCompositionStart', | ||
'onCompositionUpdate', | ||
'onKeyDown', | ||
'onKeyPress', | ||
'onKeyUp', | ||
'onFocus', | ||
'onBlur', | ||
'onChange', | ||
'onInput', | ||
'onSubmit', | ||
'onClick', | ||
'onContextMenu', | ||
'onDblClick', | ||
'onDoubleClick', | ||
'onDrag', | ||
'onDragEnd', | ||
'onDragEnter', | ||
'onDragExit', | ||
'onDragLeave', | ||
'onDragOver', | ||
'onDragStart', | ||
'onDrop', | ||
'onMouseDown', | ||
'onMouseEnter', | ||
'onMouseLeave', | ||
'onMouseMove', | ||
'onMouseOut', | ||
'onMouseOver', | ||
'onMouseUp', | ||
'onSelect', | ||
'onTouchCancel', | ||
'onTouchEnd', | ||
'onTouchMove', | ||
'onTouchStart', | ||
'onScroll', | ||
'onWheel', | ||
'onAbort', | ||
'onCanPlay', | ||
'onCanPlayThrough', | ||
'onDurationChange', | ||
'onEmptied', | ||
'onEncrypted', | ||
'onEnded', | ||
'onError', | ||
'onLoadedData', | ||
'onLoadedMetadata', | ||
'onLoadStart', | ||
'onPause', | ||
'onPlay', | ||
'onPlaying', | ||
'onProgress', | ||
'onRateChange', | ||
'onSeeked', | ||
'onSeeking', | ||
'onStalled', | ||
'onSuspend', | ||
'onTimeUpdate', | ||
'onVolumeChange', | ||
'onWaiting', | ||
'onLoad', | ||
'onError', | ||
'onAnimationStart', | ||
'onAnimationEnd', | ||
'onAnimationIteration', | ||
'onTransitionEnd', | ||
] | ||
*/ | ||
``` | ||
Contains a flat list of common event handler props used in JSX to attach behaviors | ||
to DOM events. | ||
#### eventHandlersByType | ||
The same list as `eventHandlers`, grouped into types. | ||
```js | ||
console.log(eventHandlersByType); | ||
/* | ||
{ | ||
clipboard: [ 'onCopy', 'onCut', 'onPaste' ], | ||
composition: [ 'onCompositionEnd', 'onCompositionStart', 'onCompositionUpdate' ], | ||
keyboard: [ 'onKeyDown', 'onKeyPress', 'onKeyUp' ], | ||
focus: [ 'onFocus', 'onBlur' ], | ||
form: [ 'onChange', 'onInput', 'onSubmit' ], | ||
mouse: [ 'onClick', 'onContextMenu', 'onDblClick', 'onDoubleClick', 'onDrag', 'onDragEnd', 'onDragEnter', 'onDragExit', 'onDragLeave', 'onDragOver', 'onDragStart', 'onDrop', 'onMouseDown', 'onMouseEnter', 'onMouseLeave', 'onMouseMove', 'onMouseOut', 'onMouseOver', 'onMouseUp' ], | ||
selection: [ 'onSelect' ], | ||
touch: [ 'onTouchCancel', 'onTouchEnd', 'onTouchMove', 'onTouchStart' ], | ||
ui: [ 'onScroll' ], | ||
wheel: [ 'onWheel' ], | ||
media: [ 'onAbort', 'onCanPlay', 'onCanPlayThrough', 'onDurationChange', 'onEmptied', 'onEncrypted', 'onEnded', 'onError', 'onLoadedData', 'onLoadedMetadata', 'onLoadStart', 'onPause', 'onPlay', 'onPlaying', 'onProgress', 'onRateChange', 'onSeeked', 'onSeeking', 'onStalled', 'onSuspend', 'onTimeUpdate', 'onVolumeChange', 'onWaiting' ], | ||
image: [ 'onLoad', 'onError' ], | ||
animation: [ 'onAnimationStart', 'onAnimationEnd', 'onAnimationIteration' ], | ||
transition: [ 'onTransitionEnd' ], | ||
} | ||
*/ | ||
``` |
@@ -13,6 +13,5 @@ import propName from './propName'; | ||
export default function getProp(props = [], prop = '', options = DEFAULT_OPTIONS) { | ||
let nodeProp; | ||
const propToFind = options.ignoreCase ? prop.toUpperCase() : prop; | ||
const hasProp = props.some((attribute) => { | ||
return props.find((attribute) => { | ||
// If the props contain a spread prop, then skip. | ||
@@ -27,11 +26,4 @@ if (attribute.type === 'JSXSpreadAttribute') { | ||
if (propToFind === currentProp) { | ||
nodeProp = attribute; | ||
return true; | ||
} | ||
return false; | ||
return propToFind === currentProp; | ||
}); | ||
return hasProp ? nodeProp : undefined; | ||
} |
import hasProp, { hasAnyProp, hasEveryProp } from './hasProp'; | ||
import elementType from './elementType'; | ||
import eventHandlers, { eventHandlersByType } from './eventHandlers'; | ||
import getProp from './getProp'; | ||
@@ -12,2 +13,4 @@ import getPropValue, { getLiteralPropValue } from './getPropValue'; | ||
elementType, | ||
eventHandlers, | ||
eventHandlersByType, | ||
getProp, | ||
@@ -14,0 +17,0 @@ getPropValue, |
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
239795
1
81
3078
280
13
- Removedacorn-jsx@^3.0.1
- Removedacorn@3.3.0(transitive)
- Removedacorn-jsx@3.0.1(transitive)