Skip to content
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

fix(runtime-dom): true-value and false-value not working on first render #2696

Closed
wants to merge 4 commits into from

Conversation

edison1105
Copy link
Member

close #2694

Copy link
Member

@posva posva left a comment

Choose a reason for hiding this comment

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

Could you add a test too?

@@ -126,6 +126,13 @@ export const vModelCheckbox: ModelDirective<HTMLInputElement> = {
}
})
},
mounted(el, { value }) {
Copy link
Member

Choose a reason for hiding this comment

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

The fix is likely to happen somewhere else, otherwise, it wouldn't work for SSR

Copy link
Member Author

Choose a reason for hiding this comment

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

Could you add a test too?

of course.I will do it later.

Copy link
Member

Choose a reason for hiding this comment

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

Runtime directives are never used during SSR anyway

@yyx990803
Copy link
Member

Sorry, I just saw this after I pushed 48f00c0 (note it just moves the setChecked call)

@yyx990803 yyx990803 closed this Dec 1, 2020
@yyx990803
Copy link
Member

It does occur to me that true-value and false-value are not properly handled for SSR.

@edison1105
Copy link
Member Author

Sorry, I just saw this after I pushed 48f00c0 (note it just moves the setChecked call)

@yyx990803
I know this and tested it already. Unfortunately this is not working.
We should assign true-value or false-value to checkbox but setChecked is not do this after first render.

<div id="app">
  <label>model {{ model }}</label>
  <input type="checkbox" v-model="model" :true-value="11" :false-value="22" />
</div>

<script>
  const { ref,createApp } = Vue
  createApp({
    name: "App",
    setup() {
      const model = ref(false);
      return {
        model,
      };
    },
  }).mount('#app')
</script>

After first render,the model value is still false not 22.
image

And my PR is make it works fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

true-value and false-value are ignored on initial render
3 participants