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

jsx-ast-utils

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsx-ast-utils - npm Package Compare versions

Comparing version 1.3.5 to 1.4.0

__tests__/src/eventHandlers-test.js

5

CHANGELOG.md

@@ -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 @@ ==================

12

lib/getProp.js

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

@@ -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,

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