Skip to content

Commit 4c36871

Browse files
committed
prefixed formly components so they don't conflict with native ones
1 parent 4dd5491 commit 4c36871

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

src/components/FormlyField.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
<template>
2-
<component :is="form[key].type" :form.sync="form" :key="key"></component>
2+
<component :is="type" :form.sync="form" :key="key"></component>
33
</template>
44

55
<script>
66
const Vue = require('vue');
77
import Util, {getTypes} from '../util';
88
export default {
99
props: ['form', 'key'],
10+
computed: {
11+
type:function(){
12+
return 'formly_'+this.form[this.key].type;
13+
}
14+
},
1015
components: getTypes()
1116
}
1217
</script>

src/util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export default exports;
99
* @param {Object} options
1010
*/
1111
export function addType(id, options){
12-
exports.formlyFields[id] = options;
12+
exports.formlyFields['formly_'+id] = options;
1313
}
1414

1515
export function getTypes(){

test/unit/specs/FormlyField.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('FormlyField', () => {
2323

2424
it('should take on the type of another component', () => {
2525

26-
Vue.component('test', {
26+
Vue.component('formly_test', {
2727
props: ['form', 'key'],
2828
template: '<div id="testComponent">{{form[key].type}}</div>'
2929
});
@@ -46,7 +46,7 @@ describe('FormlyField', () => {
4646

4747
it('should mimic the model of the parent', (done) => {
4848

49-
Vue.component('test', {
49+
Vue.component('formly_test', {
5050
props: ['form', 'key'],
5151
template: '<input type="text" id="testInput" v-model="form[key].value">'
5252
});

test/unit/specs/index.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('module', () => {
2929
foo: 'bar'
3030
};
3131
addType('test', newField);
32-
expect(getTypes().test).to.deep.equal(newField);
32+
expect(getTypes().formly_test).to.deep.equal(newField);
3333
});
3434

3535
});

0 commit comments

Comments
 (0)