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

domProps set to null or undefined are set to '' on update. #9650

Comments

@code-elf
Copy link

code-elf commented Mar 7, 2019

Version

2.6.8

Reproduction link

https://jsfiddle.net/bqzu8crg/

Steps to reproduce

Since this change, whenever an element updates which has one of its domProps set to undefined or null, that prop is instead set to ''.
All you need to do to reproduce it is render an element with properties in domProps set to null or undefined, and then update the component.

What is expected?

The domProps values retain their correct types.

What is actually happening?

The domProps become strings, instead.

@posva
Copy link
Member

posva commented Mar 7, 2019

This is expected because a dom prop is casted by the browser into a string

@posva posva closed this as completed Mar 7, 2019
@code-elf
Copy link
Author

code-elf commented Mar 7, 2019

@posva What browser casts dom props into strings? They're not attributes and not expressed as such, and I've been using domProps to attach data to elements without issues across all browsers. There are, in fact, plenty of properties (not attributes!) on HTMLElement instances that are not strings. Please reopen this issue.

@Justineo Justineo reopened this Mar 8, 2019
@Justineo
Copy link
Member

Justineo commented Mar 8, 2019

It seems that now when domProps are updated, undefined and null will be converted to '' (empty string).

@posva
Copy link
Member

posva commented Mar 8, 2019 via email

@pistis
Copy link

pistis commented Mar 19, 2019

@posva
@MayaWolf
I have tested this link in v2.6.9 with minor modifications.
(https://jsfiddle.net/pistis/5whnyt0q/6/)

When the x value of domProps is set to undefined
Test Scenario 1

  1. Click the 'Click me' button
  2. The value of document.getElementById('test').x is set to 'undefined'

Test Scenario 2

  1. Click the 'Update' button
  2. Click the 'Click me' button
  3. The value of document.getElementById('test').x is 2 when this is done.

Also, if x value of domProps is set to null, the same result as above is displayed.

I estimate the following.

  1. The value of the initial domProps is set correctly.
  2. When DOM with domProps is updated via render, undefined and null are converted to empty string in vnode -> Real DOM conversion.

kiku-jw pushed a commit to kiku-jw/vue that referenced this issue Jun 18, 2019
Lostlover pushed a commit to Lostlover/vue that referenced this issue Dec 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment