-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
<div>{ new String('hi') }</div> renders blank #4151
Comments
I think you would have to call |
Can you please explain that attack? As I showed in the Colab, React supports the Seems like you could do something like change: if (newVNode.constructor !== undefined) return null; to if (newVNode.toString) // or newVNode.constructor === String
newVNode = newVNode.toString();
else if (newVNode.constructor !== undefined) return null; |
That's not it. `abc`.constructor === String |
In `constructNewChildrenArray` we look for the `String` constructor to support #4151 (i.e. strings created with `new String`). However, doing this check first leads to a megamorphic deopt in `constructorNewChildrenArray` since V8 has many different internal types for strings, leading to a megamorphic access for `childVNode.constructor` in the common case (normal strings and VNodes). This PR adds back the `typeof childVNode == 'string'` check to catch normal strings first before falling back to `childVNode.constructor == String` to check for manually constructed strings. Commits: * Add back typeof string check in diffChildren (+5 B) * Store matching oldVNode in variable in constructNewChildrenArray (-4 B) * Inline insertion checks into skew block (-3 B)
Describe the bug
doesn't render the string. This works in React.
To Reproduce
React and Preact are both shown here
Note
Normally I would just render a string primitive; however, some of the strings I want to render may have metadata attached to them (not relevant to the render, but useful in the app).
is illegal; however,
works. Thus, I'm trying to figure out how I can have an object that is treated like a string e.g. by Preact, but can have metadata attached when needed.
The text was updated successfully, but these errors were encountered: