baiyaaaaa 8 жил өмнө
parent
commit
b63cb5e066

+ 1 - 1
examples/docs/zh-cn/input.md

@@ -244,8 +244,8 @@
 ```html
 <el-input
   type="textarea"
+  autosize
   placeholder="请输入内容"
-  :autosize="{minRows: 2, maxRows: 5}"
   v-model="textarea">
 </el-input>
 ```

+ 0 - 2
packages/input/src/input.vue

@@ -120,7 +120,6 @@
         this.$emit('onblur', this.currentValue);
         this.dispatch('form-item', 'el.form.blur', [this.currentValue]);
       },
-
       inputSelect() {
         this.$refs.input.select();
       },
@@ -169,7 +168,6 @@
       'value'(val, oldValue) {
         this.currentValue = val;
       },
-
       'currentValue'(val) {
         this.$nextTick(_ => {
           this.resizeTextarea();

+ 0 - 1
packages/theme-default/src/input.css

@@ -50,7 +50,6 @@
         vertical-align: middle;
       }
 
-
       & + .el-input__inner {
         padding-right: 35px;
       }

+ 2 - 2
src/index.js

@@ -55,7 +55,7 @@ import Steps from '../packages/steps/index.js';
 import Step from '../packages/step/index.js';
 
 const install = function(Vue) {
-  /* istanbul ignore next */
+  /* istanbul ignore if */
   if (install.installed) return;
 
   Vue.component(Pagination.name, Pagination);
@@ -120,7 +120,7 @@ const install = function(Vue) {
   Vue.prototype.$message = Message;
 };
 
-/* istanbul ignore next */
+/* istanbul ignore if */
 if (typeof window !== 'undefined' && window.Vue) {
   install(window.Vue);
 };

+ 99 - 0
test/unit/specs/input.spec.js

@@ -0,0 +1,99 @@
+import { createVue } from '../util';
+
+describe('Input', () => {
+  it('create', () => {
+    const vm = createVue({
+      template: `
+        <el-input
+          minlength="3"
+          maxlength="5"
+          placeholder="请输入内容"
+          value="input">
+        </el-input>
+      `
+    }, true);
+    let inputElm = vm.$el.querySelector('input');
+    expect(inputElm.getAttribute('placeholder')).to.equal('请输入内容');
+    expect(inputElm.value).to.equal('input');
+    expect(inputElm.getAttribute('minlength')).to.equal('3');
+    expect(inputElm.getAttribute('maxlength')).to.equal('5');
+  });
+
+  it('disabled', () => {
+    const vm = createVue({
+      template: `
+        <el-input disabled>
+        </el-input>
+      `
+    }, true);
+    expect(vm.$el.querySelector('input').getAttribute('disabled')).to.ok;
+  });
+
+  it('icon', () => {
+    const vm = createVue({
+      template: `
+        <el-input icon="time">
+        </el-input>
+      `
+    }, true);
+    expect(vm.$el.querySelector('.el-input__icon').classList.contains('el-icon-time')).to.true;
+  });
+
+  it('size', () => {
+    const vm = createVue({
+      template: `
+        <el-input size="large">
+        </el-input>
+      `
+    }, true);
+
+    expect(vm.$el.classList.contains('el-input-large')).to.true;
+  });
+
+  it('type', () => {
+    const vm = createVue({
+      template: `
+        <el-input type="textarea">
+        </el-input>
+      `
+    }, true);
+
+    expect(vm.$el.classList.contains('el-textarea')).to.true;
+  });
+
+  it('rows', () => {
+    const vm = createVue({
+      template: `
+        <el-input type="textarea" :rows="3">
+        </el-input>
+      `
+    }, true);
+    expect(vm.$el.querySelector('.el-textarea__inner').getAttribute('rows')).to.be.equal('3');
+  });
+  it('autosize', done => {
+    const vm = createVue({
+      template: `
+        <el-input
+          type="textarea"
+          autosize="{minRows: 3, maxRows: 5}"
+          v-model="textareaValue"
+        >
+        </el-input>
+      `,
+      data() {
+        return {
+          textareaValue: 'sda\ndasd\nddasdsda\ndasd\nddasdsda\ndasd\nddasdsda\ndasd\nddasd'
+        };
+      }
+    }, true).$children[0];
+
+    var originHeight = vm.textareaStyle.height;
+    expect(originHeight).to.be.not.equal('117px');
+
+    vm.$parent.textareaValue = '';
+    setTimeout(_ => {
+      expect(vm.textareaStyle.height).to.be.not.equal('54px');
+      done();
+    }, 200);
+  });
+});