-
Notifications
You must be signed in to change notification settings - Fork 668
docs: improve document for setChecked(), setSelected() and setValue() #728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
780d4f6
cb6a588
2391f6a
314632c
d7b6afb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
## setChecked(value) | ||
## setChecked(checked) | ||
|
||
Sets the value of a radio or checkbox `<input>`. | ||
Sets the value to an input element of type checkbox or an input element of type radio. | ||
|
||
When you try to set the value to state via `v-model` by `radioInput.element.checked = true; radioInput.trigger('input')`, `v-model` is not triggered. `v-model` is triggered by `change` event. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should add this to a |
||
|
||
`checkboxInput.setChecked(checked)` is an alias of the following code. | ||
|
||
```js | ||
checkboxInput.element.checked = checked | ||
checkboxInput.trigger('click') | ||
checkboxInput.trigger('change') | ||
``` | ||
|
||
- **Arguments:** | ||
- `{Boolean} selected` | ||
- `{Boolean} checked (default: true)` | ||
|
||
- **Example:** | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
## setSelected(value) | ||
## setSelected() | ||
|
||
Sets a specified `<option>` as selected in a `<select>`. | ||
Selects a option element. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Selects a option element.
|
||
|
||
- **Arguments:** | ||
- `{Boolean} selected` | ||
When you try to set the value to state via `v-model` by `option.element.selected = true; parentSelect.trigger('input')`, `v-model` is not triggered. `v-model` is triggered by `change` event. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also move this to a |
||
|
||
`option.setchecked(checked)` is an alias of the following code. | ||
|
||
```js | ||
option.element.selected = true | ||
parentSelect.trigger('change') | ||
``` | ||
|
||
- **Example:** | ||
|
||
|
@@ -15,5 +21,4 @@ const wrapper = shallowMount(Foo) | |
const options = wrapper.find('select').findAll('option') | ||
|
||
options.at(1).setSelected() | ||
expect(wrapper.text()).to.contain('option1') | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
## setValue(value) | ||
|
||
Sets the value of a text `<input>`. | ||
Sets the value to an input element of type text. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sets the value to an input element of type text.
|
||
|
||
`textInput.setValue(value)` is an alias of the following code. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you also move this to notes |
||
|
||
```js | ||
textInput.element.value = value | ||
textInput.trigger('input') | ||
``` | ||
|
||
- **Arguments:** | ||
- `{String} value` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should change this to mention the v-model:
Sets checked value for input element of type checkbox or radio and updates
v-modelbound data.