The Wayback Machine - https://web.archive.org/web/20190322210303/https://github.com/vuejs/vue/issues/9650
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

Closed
MayaWolf opened this Issue Mar 7, 2019 · 5 comments
Closed

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

MayaWolf opened this Issue Mar 7, 2019 · 5 comments

Comments

Projects
None yet
4 participants
@MayaWolf
Copy link

MayaWolf 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

This comment has been minimized.

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 Mar 7, 2019

@MayaWolf

This comment has been minimized.

Copy link
Author

MayaWolf 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

This comment has been minimized.

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

This comment has been minimized.

Copy link
Member

posva commented Mar 8, 2019

@pistis

This comment has been minimized.

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.

@yyx990803 yyx990803 closed this in f11449d Mar 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.