diff --git a/lib/index.js b/lib/index.js index eb3111a..144a5aa 100644 --- a/lib/index.js +++ b/lib/index.js @@ -215,6 +215,12 @@ function getVNodeProps(t, astProps, isComponent) { if (!isComponent && (propName === 'className' || propName === 'class')) { className = getValue(t, astProp.value); + } else if (!isComponent && (propName === 'htmlFor')) { + props.push({ + astName: getName(t, 'for'), + astValue: getValue(t, astProp.value), + astSpread: null + }) } else if (propName.substr(0, 11) === 'onComponent' && isComponent) { if (!ref) { ref = t.ObjectExpression([]); diff --git a/package.json b/package.json index 6856a56..6c3f5e0 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ "mocha": "^3.2.0" }, "scripts": { - "test": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha tests.js", + "coverage": "./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha tests.js", + "test": "./node_modules/.bin/_mocha tests.js", "lint": "eslint lib", "lintfix": "eslint lib --fix" }, diff --git a/tests.js b/tests.js index 4bc11a3..480e5c0 100644 --- a/tests.js +++ b/tests.js @@ -51,6 +51,12 @@ describe('Array', function() { it('Events should be in props', function () { expect(transform('
1
')).to.equal('createVNode(2, "div", variable, "1", {\n "id": "test",\n "onClick": func\n});'); }); + + it('Should transform input and htmlFor correctly', function () { + var result = transform(''); + var expected = 'createVNode(2, "label", null, createVNode(512, "input", null, null, {\n "id": id,\n "name": name,\n "value": value,\n "onChange": onChange,\n "onInput": onInput,\n "onKeyup": onKeyup,\n "onFocus": onFocus,\n "onClick": onClick,\n "type": "number",\n "pattern": "[0-9]+([,.][0-9]+)?",\n "inputMode": "numeric",\n "min": minimum\n}), {\n "for": id\n});'; + expect(result).to.equal(expected); + }); }); /**