babel-plugin-transform-vue-jsx
Advanced tools
Comparing version 3.4.1 to 3.4.2
@@ -28,3 +28,3 @@ var esutils = require('esutils') | ||
}, | ||
'ObjectExpression|ClassDeclaration' (path) { | ||
'Program' (path) { | ||
path.traverse({ | ||
@@ -151,6 +151,6 @@ 'ObjectMethod|ClassMethod' (path) { | ||
// add prop merging helper | ||
file.addImport('babel-helper-vue-jsx-merge-props', 'default', '_mergeJSXProps') | ||
var helper = file.addImport('babel-helper-vue-jsx-merge-props', 'default', '_mergeJSXProps') | ||
// spread it | ||
attribs = t.callExpression( | ||
t.identifier('_mergeJSXProps'), | ||
helper, | ||
[t.arrayExpression(objs)] | ||
@@ -157,0 +157,0 @@ ) |
{ | ||
"name": "babel-plugin-transform-vue-jsx", | ||
"version": "3.4.1", | ||
"version": "3.4.2", | ||
"description": "Babel plugin for Vue 2.0 JSX", | ||
"main": "index.js", | ||
"unpkg": "dist/babel-plugin-transform-vue-jsx.min.js", | ||
"files": [ | ||
"index.js", | ||
"lib" | ||
"lib", | ||
"dist" | ||
], | ||
@@ -13,3 +15,5 @@ "scripts": { | ||
"test": "npm run lint && mocha --compilers js:babel-register", | ||
"dev": "cd example && webpack --watch" | ||
"dev": "cd example && webpack --watch", | ||
"build": "webpack -p index.js dist/babel-plugin-transform-vue-jsx.min.js --target=web --output-library=babel-plugin-transform-vue-jsx --output-library-target=umd --module-bind 'js=babel-loader'", | ||
"prepubish": "npm run build" | ||
}, | ||
@@ -16,0 +20,0 @@ "repository": { |
@@ -58,5 +58,6 @@ # 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) | ||
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. | ||
Starting with version 3.4.0 we automatically inject `const h = this.$createElement` in any method and getter (not functions or arrow functions) declared in ES2015 syntax that has JSX so you can drop the `(h)` parameter. | ||
``` js | ||
Vue.component('jsx-example', { | ||
@@ -68,8 +69,16 @@ render () { // h will be injected | ||
return <div id="foo">bar</div> | ||
}, | ||
someOtherMethod: () => { // h will not be injected | ||
return <div id="foo">bar</div> | ||
} | ||
}) | ||
@Component | ||
class App extends Vue { | ||
get computed () { // h will 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 | ||
@@ -76,0 +85,0 @@ |
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
47638
6
373
208