diff --git a/src/packages/__VUE/inputnumber/__tests__/__snapshots__/index.spec.ts.snap b/src/packages/__VUE/inputnumber/__tests__/__snapshots__/index.spec.tsx.snap similarity index 100% rename from src/packages/__VUE/inputnumber/__tests__/__snapshots__/index.spec.ts.snap rename to src/packages/__VUE/inputnumber/__tests__/__snapshots__/index.spec.tsx.snap diff --git a/src/packages/__VUE/inputnumber/__tests__/index.spec.ts b/src/packages/__VUE/inputnumber/__tests__/index.spec.tsx similarity index 91% rename from src/packages/__VUE/inputnumber/__tests__/index.spec.ts rename to src/packages/__VUE/inputnumber/__tests__/index.spec.tsx index abb3528105..d793283425 100644 --- a/src/packages/__VUE/inputnumber/__tests__/index.spec.ts +++ b/src/packages/__VUE/inputnumber/__tests__/index.spec.tsx @@ -4,12 +4,9 @@ import { h, nextTick } from 'vue' import { Left, Right } from '@nutui/icons-vue' test('InputNumber: should render modelValue', () => { - const wrapper = mount(InputNumber, { - props: { - modelValue: 12 - } + const wrapper = mount(() => { + return }) - const input = wrapper.find('input').element as HTMLInputElement expect(input.value).toBe('12') }) @@ -189,3 +186,15 @@ test('InputNumber: should change modelValue after props.min was changed', async expect(wrapper.emitted()['update:modelValue']).toHaveLength(1) expect(wrapper.emitted()['update:modelValue'][0]).toStrictEqual(['7', {}]) }) + +test('InputNumber: v-bind="$attrs"', async () => { + const testClass = 'test-attr-class' + const customAttr = 'custom-attr' + const wrapper = mount(() => { + return + }) + + const input = wrapper.find('input').element as HTMLInputElement + expect(input.getAttribute('class')).includes(testClass) + expect(input.getAttribute(customAttr)).includes(customAttr) +}) diff --git a/src/packages/__VUE/inputnumber/doc.en-US.md b/src/packages/__VUE/inputnumber/doc.en-US.md index 9b4c565c62..f7e9e9cded 100644 --- a/src/packages/__VUE/inputnumber/doc.en-US.md +++ b/src/packages/__VUE/inputnumber/doc.en-US.md @@ -74,6 +74,10 @@ Set step size `step` 0.1 `decimal places` keep 1 decimal place | disabled | Disable all features | boolean | `false` | | readonly | Read only status disables input box operation behavior | boolean | `false` | +### Attrs version + +The attributes on `InputNumber` will be inherited by `input` element. + ### Slots | Name | Description | diff --git a/src/packages/__VUE/inputnumber/doc.md b/src/packages/__VUE/inputnumber/doc.md index 0bb5f3162d..4b22df2193 100644 --- a/src/packages/__VUE/inputnumber/doc.md +++ b/src/packages/__VUE/inputnumber/doc.md @@ -74,6 +74,10 @@ app.use(InputNumber) | disabled | 禁用所有功能 | boolean | `false` | | readonly | 只读状态禁用输入框操作行为 | boolean | `false` | +### Attrs version + +支持透传属性至组件内部的 input 元素。 + ### Slots | 名称 | 说明 | diff --git a/src/packages/__VUE/inputnumber/doc.taro.md b/src/packages/__VUE/inputnumber/doc.taro.md index ea4dbf1e68..cbf6dc66b0 100644 --- a/src/packages/__VUE/inputnumber/doc.taro.md +++ b/src/packages/__VUE/inputnumber/doc.taro.md @@ -74,6 +74,10 @@ app.use(InputNumber) | disabled | 禁用所有功能 | boolean | `false` | | readonly | 只读状态禁用输入框操作行为 | boolean | `false` | +### Attrs version + +支持透传属性至组件内部的 input 元素。 + ### Slots | 名称 | 说明 | diff --git a/src/packages/__VUE/inputnumber/input-number.taro.vue b/src/packages/__VUE/inputnumber/input-number.taro.vue index 3a9741bb03..b684f84b45 100644 --- a/src/packages/__VUE/inputnumber/input-number.taro.vue +++ b/src/packages/__VUE/inputnumber/input-number.taro.vue @@ -16,6 +16,7 @@ v-else class="nut-input-number__text--input" type="number" + v-bind="$attrs" :min="min" :max="max" :style="{ width: pxCheck(inputWidth), height: pxCheck(buttonSize) }" @@ -44,7 +45,8 @@ import { Minus, Plus } from '@nutui/icons-vue-taro' import { useFormDisabled } from '../form/common' defineOptions({ - name: 'NutInputNumber' + name: 'NutInputNumber', + inheritAttrs: false }) export type InputNumberProps = Partial<{ diff --git a/src/packages/__VUE/inputnumber/input-number.vue b/src/packages/__VUE/inputnumber/input-number.vue index b55bd658af..c89fcedb0a 100644 --- a/src/packages/__VUE/inputnumber/input-number.vue +++ b/src/packages/__VUE/inputnumber/input-number.vue @@ -11,6 +11,7 @@