Skip to content

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

Merged
merged 5 commits into from
Jun 18, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions docs/api/wrapper/setChecked.md
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.
Copy link
Member

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-model bound data.


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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add this to a notes sections after the arguments and example, I don't think most users need this info


`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:**

Expand Down
15 changes: 10 additions & 5 deletions docs/api/wrapper/setSelected.md
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Selects a option element.

Selects a option element and updates v-model bound data.


- **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.
Copy link
Member

@eddyerburgh eddyerburgh Jun 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also move this to a - **Notes:** section


`option.setchecked(checked)` is an alias of the following code.

```js
option.element.selected = true
parentSelect.trigger('change')
```

- **Example:**

Expand All @@ -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')
```
9 changes: 8 additions & 1 deletion docs/api/wrapper/setValue.md
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sets the value to an input element of type text.

Sets value of a text-control input element and updates v-model bound data


`textInput.setValue(value)` is an alias of the following code.
Copy link
Member

@eddyerburgh eddyerburgh Jun 17, 2018

Choose a reason for hiding this comment

The 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`
Expand Down