You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently in setProp we make some decisions when to use setAttribute and when to use direct property assignment, etc. For example, if user provides draggable=true (boolean) we set it with direct assignment because setAttribute wouldn't work as 'draggable' is not a boolean (https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/draggable). Direct assignment apparently leads to 'true' being coerced into a string and thus it works.
Anyway: there's some if-else technology used to decide what to do in which particular case, and it will eventually get out of hand as these special cases get larger in number. We would probably benefit from having a systematic way to handle them.
For reference, here is what React does for different kinds of props (tldr: mostly setAttribute with a few exceptions, and special handling for various props like coercion to string):
Currently in setProp we make some decisions when to use setAttribute and when to use direct property assignment, etc. For example, if user provides draggable=true (boolean) we set it with direct assignment because setAttribute wouldn't work as 'draggable' is not a boolean (https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/draggable). Direct assignment apparently leads to 'true' being coerced into a string and thus it works.
Anyway: there's some if-else technology used to decide what to do in which particular case, and it will eventually get out of hand as these special cases get larger in number. We would probably benefit from having a systematic way to handle them.
For reference, here is what React does for different kinds of props (tldr: mostly setAttribute with a few exceptions, and special handling for various props like coercion to string):
https://github.com/facebook/react/blob/b61174fb7b09580c1ec2a8f55e73204b706d2935/packages/react-dom/src/shared/DOMProperty.js
The text was updated successfully, but these errors were encountered: