babel-plugin-transform-vue-jsx
Advanced tools
Comparing version 2.0.1 to 2.0.2
var makeMap = require('./make-map') | ||
var isTopLevel = makeMap('class,staticClass,style,key,ref,slot') | ||
var isNestable = makeMap('domProps,on,nativeOn,hook') | ||
@@ -9,32 +10,33 @@ module.exports = function groupProps (props, t) { | ||
var name = prop.key.value || prop.key.name | ||
var prefixIndex | ||
if (isTopLevel(name)) { | ||
// top-level special props | ||
newProps.push(prop) | ||
} else if ((prefixIndex = name.indexOf('-')) > 0) { | ||
// nested | ||
var prefix = name.slice(0, prefixIndex) | ||
var suffix = name.slice(prefixIndex + 1) | ||
var nestedProp = t.objectProperty(t.identifier(suffix), prop.value) | ||
var nestedObject = currentNestedObjects[prefix] | ||
if (!nestedObject) { | ||
nestedObject = currentNestedObjects[prefix] = t.objectProperty( | ||
t.identifier(prefix), | ||
t.objectExpression([nestedProp]) | ||
) | ||
newProps.push(nestedObject) | ||
} else { | ||
nestedObject.value.properties.push(nestedProp) | ||
} | ||
} else { | ||
// rest are nested under attrs | ||
var attrs = currentNestedObjects.attrs | ||
if (!attrs) { | ||
attrs = currentNestedObjects.attrs = t.objectProperty( | ||
t.identifier('attrs'), | ||
t.objectExpression([prop]) | ||
) | ||
newProps.push(attrs) | ||
var prefixIndex = name.indexOf('-') | ||
var prefix = prefixIndex > 0 && name.slice(0, prefixIndex) | ||
if (prefix && isNestable(prefix)) { | ||
var suffix = name.slice(prefixIndex + 1) | ||
var nestedProp = t.objectProperty(t.identifier(suffix), prop.value) | ||
var nestedObject = currentNestedObjects[prefix] | ||
if (!nestedObject) { | ||
nestedObject = currentNestedObjects[prefix] = t.objectProperty( | ||
t.identifier(prefix), | ||
t.objectExpression([nestedProp]) | ||
) | ||
newProps.push(nestedObject) | ||
} else { | ||
nestedObject.value.properties.push(nestedProp) | ||
} | ||
} else { | ||
attrs.value.properties.push(prop) | ||
// rest are nested under attrs | ||
var attrs = currentNestedObjects.attrs | ||
if (!attrs) { | ||
attrs = currentNestedObjects.attrs = t.objectProperty( | ||
t.identifier('attrs'), | ||
t.objectExpression([prop]) | ||
) | ||
newProps.push(attrs) | ||
} else { | ||
attrs.value.properties.push(prop) | ||
} | ||
} | ||
@@ -41,0 +43,0 @@ } |
{ | ||
"name": "babel-plugin-transform-vue-jsx", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Babel plugin for Vue 2.0 JSX", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
11436
200