Skip to content

Commit 3cae614

Browse files
committed
Can now bind any listener provided by user to the input
1 parent f639863 commit 3cae614

File tree

3 files changed

+24
-7
lines changed

3 files changed

+24
-7
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"karma-spec-reporter": "^0.0.31",
5757
"karma-webpack": "^2.0.4",
5858
"mocha": "^3.5.0",
59+
"phantomjs-polyfill-object-assign": "0.0.2",
5960
"phantomjs-prebuilt": "^2.1.15",
6061
"sinon": "^3.2.1",
6162
"sinon-chai": "^2.13.0",

src/vue-numeric.vue

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
<template>
22
<input
3-
:placeholder="placeholder"
4-
@blur="onBlurHandler"
5-
@input="onInputHandler"
6-
@focus="onFocusHandler"
3+
v-if="!readOnly"
74
ref="numeric"
8-
type="tel"
95
v-model="amount"
10-
v-if="!readOnly"
6+
:placeholder="placeholder"
7+
type="tel"
8+
v-on="inputListeners"
119
>
1210
<span
1311
v-else
@@ -195,6 +193,21 @@ export default {
195193
return ','
196194
},
197195
196+
/**
197+
* Define listeners to attach to the input
198+
*/
199+
inputListeners () {
200+
var vm = this;
201+
return Object.assign({},
202+
this.$listeners,
203+
{
204+
blur: vm.onBlurHandler,
205+
input: vm.onInputHandler,
206+
focus: vm.onFocusHandler,
207+
}
208+
);
209+
},
210+
198211
/**
199212
* Define thousand separator based on separator props.
200213
* @return {String} '.' or ','

test/karma.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ module.exports = config => {
77
browsers: ['PhantomJS'],
88
frameworks: ['mocha', 'sinon-chai'],
99
reporters: ['spec', 'coverage'],
10-
files: ['specs/*.spec.js'],
10+
files: [
11+
'../node_modules/phantomjs-polyfill-object-assign/object-assign-polyfill.js',
12+
'specs/*.spec.js'
13+
],
1114
preprocessors: {
1215
'./specs/*.spec.js': ['webpack', 'sourcemap']
1316
},

0 commit comments

Comments
 (0)