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

babel-plugin-transform-vue-jsx

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-vue-jsx - npm Package Compare versions

Comparing version 3.3.0 to 3.4.0

32

index.js

@@ -27,2 +27,34 @@ var esutils = require('esutils')

}
},
'ObjectExpression|ClassDeclaration' (path) {
path.traverse({
'ObjectMethod|ClassMethod' (path) {
// do nothing if there is (h) param
if (path.get('params').length) {
return
}
// do nothing if there is no JSX inside
const jsxChecker = {
hasJsx: false
}
path.traverse({
JSXElement () {
this.hasJsx = true
}
}, jsxChecker)
if (!jsxChecker.hasJsx) {
return
}
// prepend const h = this.$createElement otherwise
path.get('body').unshiftContainer('body', t.variableDeclaration('const', [
t.variableDeclarator(
t.identifier('h'),
t.memberExpression(
t.thisExpression(),
t.identifier('$createElement')
)
)
]))
}
})
}

@@ -29,0 +61,0 @@ }

2

package.json
{
"name": "babel-plugin-transform-vue-jsx",
"version": "3.3.0",
"version": "3.4.0",
"description": "Babel plugin for Vue 2.0 JSX",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -56,2 +56,19 @@ # babel-plugin-transform-vue-jsx [![CircleCI](https://img.shields.io/circleci/project/vuejs/babel-plugin-transform-vue-jsx.svg?maxAge=2592000)](https://circleci.com/gh/vuejs/babel-plugin-transform-vue-jsx)

### `h` auto-injection
Starting with version 3.4.0 we automatically inject `const h = this.$createElement` in any method and getter declared in ES2015 syntax that has JSX so you can drop the `(h)` parameter.
``` js
Vue.component('jsx-example', {
render () { // h will be injected
return <div id="foo">bar</div>
},
myMethod: function () { // h will not be injected
return <div id="foo">bar</div>
}
})
```
**Important** `h` does not inject into functions or arrow functions, it works only in ES2015 Method Properties declaration.
### Difference from React JSX

@@ -58,0 +75,0 @@

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