Commit 8e34408d authored by kingwl's avatar kingwl Committed by baiyaaaaa

Input: fix invalid resize prop (#2838)

parent 00fcf06e
import merge from 'element-ui/src/utils/merge';
let hiddenTextarea; let hiddenTextarea;
const HIDDEN_STYLE = ` const HIDDEN_STYLE = `
...@@ -55,8 +53,7 @@ function calculateNodeStyling(node) { ...@@ -55,8 +53,7 @@ function calculateNodeStyling(node) {
export default function calcTextareaHeight( export default function calcTextareaHeight(
targetNode, targetNode,
minRows = null, minRows = null,
maxRows = null, maxRows = null
options = null
) { ) {
if (!hiddenTextarea) { if (!hiddenTextarea) {
hiddenTextarea = document.createElement('textarea'); hiddenTextarea = document.createElement('textarea');
...@@ -99,5 +96,5 @@ export default function calcTextareaHeight( ...@@ -99,5 +96,5 @@ export default function calcTextareaHeight(
height = Math.min(maxHeight, height); height = Math.min(maxHeight, height);
} }
return merge({ height: height + 'px'}, options); return { height: height + 'px'};
}; };
...@@ -76,6 +76,7 @@ ...@@ -76,6 +76,7 @@
<script> <script>
import emitter from 'element-ui/src/mixins/emitter'; import emitter from 'element-ui/src/mixins/emitter';
import calcTextareaHeight from './calcTextareaHeight'; import calcTextareaHeight from './calcTextareaHeight';
import merge from 'element-ui/src/utils/merge';
export default { export default {
name: 'ElInput', name: 'ElInput',
...@@ -87,7 +88,7 @@ ...@@ -87,7 +88,7 @@
data() { data() {
return { return {
currentValue: this.value, currentValue: this.value,
textareaStyle: {} textareaCalcStyle: {}
}; };
}, },
...@@ -132,6 +133,9 @@ ...@@ -132,6 +133,9 @@
computed: { computed: {
validating() { validating() {
return this.$parent.validateState === 'validating'; return this.$parent.validateState === 'validating';
},
textareaStyle() {
return merge({}, this.textareaCalcStyle, { resize: this.resize });
} }
}, },
...@@ -158,10 +162,7 @@ ...@@ -158,10 +162,7 @@
const minRows = autosize.minRows; const minRows = autosize.minRows;
const maxRows = autosize.maxRows; const maxRows = autosize.maxRows;
const options = { this.textareaCalcStyle = calcTextareaHeight(this.$refs.textarea, minRows, maxRows);
resize: this.resize
};
this.textareaStyle = calcTextareaHeight(this.$refs.textarea, minRows, maxRows, options);
}, },
handleFocus(event) { handleFocus(event) {
this.$emit('focus', event); this.$emit('focus', event);
......
...@@ -105,6 +105,28 @@ describe('Input', () => { ...@@ -105,6 +105,28 @@ describe('Input', () => {
expect(vm.$el.querySelector('.el-textarea__inner').getAttribute('rows')).to.be.equal('3'); expect(vm.$el.querySelector('.el-textarea__inner').getAttribute('rows')).to.be.equal('3');
}); });
// Github issue #2836
it('resize', done => {
vm = createVue({
template: `
<div>
<el-input type="textarea" :resize="resize"></el-input>
</div>
`,
data: {
resize: 'none'
}
}, true);
vm.$nextTick(() => {
expect(vm.$el.querySelector('.el-textarea__inner').style.resize).to.be.equal(vm.resize);
vm.resize = 'horizontal';
vm.$nextTick(() => {
expect(vm.$el.querySelector('.el-textarea__inner').style.resize).to.be.equal(vm.resize);
done();
});
});
});
it('autosize', done => { it('autosize', done => {
vm = createVue({ vm = createVue({
template: ` template: `
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment