Skip to content

Commit 8870dea

Browse files
Added disabled prop to render a disabled input rather than a span (#77)
* Added `disabled` prop to render a disabled input rather than a span * Use double quotes not single Co-authored-by: Kevin Ongko <kevin.ongko@gmail.com>
1 parent 5a6e946 commit 8870dea

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/vue-numeric.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
v-if="!readOnly"
44
ref="numeric"
55
:placeholder="placeholder"
6+
:disabled="disabled"
67
v-model="amount"
78
type="tel"
89
@blur="onBlurHandler"
@@ -154,6 +155,12 @@ export default {
154155
required: false
155156
},
156157
158+
disabled: {
159+
type: Boolean,
160+
default: false,
161+
required: false,
162+
},
163+
157164
/**
158165
* Position of currency symbol
159166
* Symbol position props accept either 'suffix' or 'prefix' (default).
@@ -162,7 +169,7 @@ export default {
162169
type: String,
163170
default: 'prefix',
164171
required: false
165-
}
172+
},
166173
},
167174
168175
data: () => ({

test/specs/vue-numeric.spec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,28 @@ describe('vue-numeric.vue', () => {
109109
})
110110
})
111111

112+
it('is is not disabled when disabled mode is disabled', done => {
113+
const propsData = { value: 3000, disabled: true }
114+
const wrapper = mount(VueNumeric, { propsData })
115+
116+
wrapper.setProps({ disabled: false })
117+
wrapper.instance().$nextTick(() => {
118+
expect(wrapper.instance().$el.hasAttribute('disabled')).to.equal(false)
119+
done()
120+
})
121+
})
122+
123+
it('is disabled in disabled mode', done => {
124+
const propsData = { value: 3000, disabled: false }
125+
const wrapper = mount(VueNumeric, { propsData })
126+
127+
wrapper.setProps({ disabled: true })
128+
wrapper.instance().$nextTick(() => {
129+
expect(wrapper.instance().$el.hasAttribute('disabled')).to.equal(true)
130+
done()
131+
})
132+
});
133+
112134
it('cannot exceed max props', () => {
113135
const component = Vue.extend({
114136
data: () => ({ total: 150 }),

0 commit comments

Comments
 (0)