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

babel-plugin-jsx-event-modifiers

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-jsx-event-modifiers - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

2

dist/bundle-test.js

@@ -1825,3 +1825,3 @@ 'use strict';

cov_28cz23z0dk.s[17]++;
return t.logicalExpression('&&', leftCondition, rightCondition);
return t.logicalExpression('||', leftCondition, rightCondition);
}));

@@ -1828,0 +1828,0 @@ } else {

@@ -92,3 +92,3 @@ 'use strict';

}).reduce(function (leftCondition, rightCondition) {
return t.logicalExpression('&&', leftCondition, rightCondition);
return t.logicalExpression('||', leftCondition, rightCondition);
}));

@@ -95,0 +95,0 @@ } else if (aliases[modifier]) {

{
"name": "babel-plugin-jsx-event-modifiers",
"version": "2.0.0",
"version": "2.0.1",
"description": "JSX Syntactic Sugar Plugin for Event Modifiers",

@@ -32,3 +32,3 @@ "main": "dist/bundle.js",

"build": "rollup --config build.js",
"prepublish": "npm run build"
"prepare": "npm run build"
},

@@ -35,0 +35,0 @@ "nyc": {

@@ -17,3 +17,3 @@ ## Event Modifiers for JSX

example .babelrc (for vue):
example .babelrc:
```json

@@ -25,12 +25,2 @@ {

```
example .babelrc (for react):
```json
{
"presets": [
"es2015",
"react"
],
"plugins": ["jsx-event-modifiers"]
}
```

@@ -37,0 +27,0 @@ #### Event Modifiers

@@ -41,3 +41,3 @@ import { aliases, keyModifiers, keyCodeRE } from './constants'

.map(keyModifier => t.memberExpression(t.identifier('$event'), t.identifier(`${keyModifier}Key`)))
.reduce((leftCondition, rightCondition) => t.logicalExpression('&&', leftCondition, rightCondition)),
.reduce((leftCondition, rightCondition) => t.logicalExpression('||', leftCondition, rightCondition)),
)

@@ -44,0 +44,0 @@ } else if (aliases[modifier]) {

@@ -7,6 +7,28 @@ # Snapshot report for `test/test.js`

## :capture-once
> :capture-once - before
'<a onEvent:capture-once={this.action1} />'
> :capture-once - compiled
`var _this = this;␊
<a {...{␊
on: {␊
"~!event": $event => {␊
_this.action1($event);␊
}␊
}␊
}} />;`
## Combine Events
> Combine Events
> Combine Events - before
'<a onEvent={this.action1} onEvent={this.action2} />'
> Combine Events - compiled
`var _this = this;␊

@@ -26,4 +48,8 @@

> Ignores attributes
> Ignores attributes - before
'<a href="#" />'
> Ignores attributes - compiled
'<a href="#" />;'

@@ -33,4 +59,8 @@

> Ignores not jsx expressions
> Ignores not jsx expressions - before
'<a onEvent="str" />'
> Ignores not jsx expressions - compiled
'<a />;'

@@ -40,4 +70,8 @@

> Ignores spread
> Ignores spread - before
'<a {...b} />'
> Ignores spread - compiled
'<a {...b} />;'

@@ -47,24 +81,18 @@

> No Events
> No Events - before
'<a />'
> No Events - compiled
'<a />;'
## Plain Event
## No key modifier but alt and shift and must be both alt and shift :bare-alt-shift
> Plain Event
> No key modifier but alt and shift and must be both alt and shift :bare-alt-shift - before
`var _this = this;␊
<a {...{␊
on: {␊
"event": $event => {␊
_this.action($event);␊
}␊
}␊
}} />;`
'<a onEvent:bare-alt-shift={this.action1} />'
## Simple :stop
> No key modifier but alt and shift and must be both alt and shift :bare-alt-shift - compiled
> Simple :stop
`var _this = this;␊

@@ -75,3 +103,3 @@

"event": $event => {␊
$event.stopPropagation();␊
if ($event.ctrlKey || $event.metaKey || !$event.altKey || !$event.shiftKey) return null;␊

@@ -83,6 +111,10 @@ _this.action1($event);␊

## Supports Dash
## Plain Event
> Supports Dash
> Plain Event - before
'<a onEvent={this.action} />'
> Plain Event - compiled
`var _this = this;␊

@@ -96,22 +128,12 @@

}␊
}} />;
}} />;`
## :capture-once
## Simple :capture
> :capture-once
> Simple :capture - before
`var _this = this;␊
<a {...{␊
on: {␊
"~!event": $event => {␊
_this.action1($event);␊
}␊
}␊
}} />;`
'<a onEvent:capture={this.action1} />'
## Simple :capture
> Simple :capture - compiled
> Simple :capture
`var _this = this;␊

@@ -129,4 +151,8 @@

> Simple :once
> Simple :once - before
'<a onEvent:once={this.action1} />'
> Simple :once - compiled
`var _this = this;␊

@@ -140,8 +166,12 @@

}␊
}} />;
}} />;`
## :bare-alt-shift
## Simple :self
> :bare-alt-shift
> Simple :self - before
'<a onEvent:self={this.action1} />'
> Simple :self - compiled
`var _this = this;␊

@@ -152,3 +182,3 @@

"event": $event => {␊
if ($event.ctrlKey && $event.metaKey || !$event.altKey || !$event.shiftKey) return null;␊
if ($event.target !== $event.currentTarget) return null;␊

@@ -160,22 +190,10 @@ _this.action1($event);␊

## Simple :alt
## Simple alias :enter
> Simple :alt
> Simple alias :enter - before
`var _this = this;␊
<a {...{␊
on: {␊
"event": $event => {␊
if (!$event.altKey) return null;␊
_this.action1($event);␊
}␊
}␊
}} />;`
'<a onEvent:enter={this.action1} />'
## Simple :bare
> Simple alias :enter - compiled
> Simple :bare
`var _this = this;␊

@@ -186,3 +204,3 @@

"event": $event => {␊
if ($event.ctrlKey && $event.shiftKey && $event.altKey && $event.metaKey) return null;␊
if (!("button" in $event) && _this._k($event.keyCode, "enter", 13)) return null;␊

@@ -194,22 +212,10 @@ _this.action1($event);␊

## Simple :prevent
## Simple double alias :delete
> Simple :prevent
> Simple double alias :delete - before
`var _this = this;␊
<a {...{␊
on: {␊
"event": $event => {␊
$event.preventDefault();␊
_this.action1($event);␊
}␊
}␊
}} />;`
'<a onEvent:delete={this.action1} />'
## Simple :self
> Simple double alias :delete - compiled
> Simple :self
`var _this = this;␊

@@ -220,3 +226,3 @@

"event": $event => {␊
if ($event.target !== $event.currentTarget) return null;␊
if (!("button" in $event) && _this._k($event.keyCode, "delete", [8, 46])) return null;␊

@@ -228,22 +234,10 @@ _this.action1($event);␊

## Simple :shift
## Simple key code :k120
> Simple :shift
> Simple key code :k120 - before
`var _this = this;␊
<a {...{␊
on: {␊
"event": $event => {␊
if (!$event.shiftKey) return null;␊
_this.action1($event);␊
}␊
}␊
}} />;
'<a onEvent:k120={this.action1} />'
## No key modifier but alt and shift and must be both alt and shift :bare-alt-shift
> Simple key code :k120 - compiled
> No key modifier but alt and shift and must be both alt and shift :bare-alt-shift
`var _this = this;␊

@@ -254,3 +248,3 @@

"event": $event => {␊
if ($event.ctrlKey && $event.metaKey || !$event.altKey || !$event.shiftKey) return null;␊
if (!("button" in $event) && $event.keyCode !== 120) return null;␊

@@ -264,4 +258,8 @@ _this.action1($event);␊

> Simple key-modifier :shift
> Simple key-modifier :shift - before
'<a onEvent:shift={this.action1} />'
> Simple key-modifier :shift - compiled
`var _this = this;␊

@@ -281,4 +279,8 @@

> Simple no-key-modifier :bare
> Simple no-key-modifier :bare - before
'<a onEvent:bare={this.action1} />'
> Simple no-key-modifier :bare - compiled
`var _this = this;␊

@@ -289,3 +291,3 @@

"event": $event => {␊
if ($event.ctrlKey && $event.shiftKey && $event.altKey && $event.metaKey) return null;␊
if ($event.ctrlKey || $event.shiftKey || $event.altKey || $event.metaKey) return null;␊

@@ -299,4 +301,8 @@ _this.action1($event);␊

> Simple preventDefault :prevent
> Simple preventDefault :prevent - before
'<a onEvent:prevent={this.action1} />'
> Simple preventDefault :prevent - compiled
`var _this = this;␊

@@ -316,20 +322,8 @@

> Simple stopPropagation :stop
> Simple stopPropagation :stop - before
`var _this = this;␊
<a {...{␊
on: {␊
"event": $event => {␊
$event.stopPropagation();␊
_this.action1($event);␊
}␊
}␊
}} />;
'<a onEvent:stop={this.action1} />'
## Simple alias :enter
> Simple stopPropagation :stop - compiled
> Simple alias :enter
`var _this = this;␊

@@ -340,3 +334,3 @@

"event": $event => {␊
if (!("button" in $event) && _this._k($event.keyCode, "enter", 13)) return null;␊
$event.stopPropagation();␊

@@ -348,22 +342,10 @@ _this.action1($event);␊

## Simple double alias :delete
## Supports Dash
> Simple double alias :delete
> Supports Dash - before
`var _this = this;␊
<a {...{␊
on: {␊
"event": $event => {␊
if (!("button" in $event) && _this._k($event.keyCode, "delete", [8, 46])) return null;␊
_this.action1($event);␊
}␊
}␊
}} />;
'<a on-event={this.action} />'
## Simple key code :k120
> Supports Dash - compiled
> Simple key code :k120
`var _this = this;␊

@@ -374,7 +356,5 @@

"event": $event => {␊
if (!("button" in $event) && $event.keyCode !== 120) return null;␊
_this.action1($event);␊
_this.action($event);␊
}␊
}␊
}} />;`
}} />;`

@@ -12,3 +12,4 @@ import test from 'ava'

test(name, t => {
t.snapshot(transpile(code), name)
t.snapshot(code, `${name} - before`)
t.snapshot(transpile(code), `${name} - compiled`)
})

@@ -15,0 +16,0 @@

Sorry, the diff of this file is not supported yet

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