-
Notifications
You must be signed in to change notification settings - Fork 668
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(slots): functional component text slots #733
fix(slots): functional component text slots #733
Conversation
@@ -19,14 +19,12 @@ function createVNodesForSlot ( | |||
slotValue, | |||
name | |||
) { | |||
if (typeof slotValue === 'string' && | |||
!startsWithTag(slotValue)) { | |||
if (typeof slotValue === 'string' && !startsWithTag(slotValue)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes are not related to the issue, files are automatically updated on yarn test
or something, but they shouldn't be included in the PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops! Thanks
if (Array.isArray(slots.default)) { | ||
return slots.default.map(h) | ||
} | ||
function startsWithTag (str) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
startsWithTag
is also defined in add-slots.js, I guess it could be extracted to some helper
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right! Actually, we could use the add-slots
files as well.
Let me refactor it 👍
@@ -17,7 +17,10 @@ function warn (msg) { | |||
|
|||
var camelizeRE = /-(\w)/g; | |||
var camelize = function (str) { | |||
var camelizedStr = str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes are not related to the issue, files are automatically updated on yarn test or something, but they shouldn't be included in the PR
6893811
to
31a3d0b
Compare
@jacekkarczmarczyk I've refactored it. But I've encountered a strange behavior: Currently, the implementation uses the
However, if I replace all calls with the Can't explain the behavior to me:man_shrugging: EDIT: And flow is failing because of types |
You've overwritten bc736fb ... |
@jacekkarczmarczyk Dang! 🙄 Still too early for me 🙈 Should look better now... |
e1d576b
to
ca7f057
Compare
Okay, one more try. I think I got it now. Test running locally and flow doesn't complain anymore 😋 |
}, []) | ||
} | ||
|
||
export function createFunctionalSlotVNodes ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to add this function, we can just use createSlotVNodes
@@ -6,7 +6,7 @@ function startsWithTag (str) { | |||
return str && str.trim()[0] === '<' | |||
} | |||
|
|||
function createVNodesForSlot ( | |||
export function createVNodesForSlot ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to export
}) | ||
return children | ||
} | ||
import { createFunctionalSlotVNodes } from './add-slots' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use createSlotVNodes instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried this, but it gave me some strange errors.
See #733 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update: Looks like this had sth. to do with wrong types. It works fine right now 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR, looks good although I think we can use the existing createSlotVnodes
function instead of the new function
edit: I've just seen your comments about karma. Can you post the errors?
ca7f057
to
0a133fd
Compare
@eddyerburgh I think those were related to flow issues as everything works fine now I've updated the PR. Hope the tests will pass like they do locally 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks 👍
A PR that removes more code than it adds, AND fixes a bug is always good!
@eddyerburgh You are welcome Cannot agree more on that! 🙊 |
@eddyerburgh Do you know when the change will be released? :) |
I'll release within a week
…On Mon, 18 Jun 2018, 12:18 Alexander Lichter, ***@***.***> wrote:
@jacekkarczmarczyk <https://github.com/jacekkarczmarczyk> Do you know
when the change will be released? :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#733 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AMlbWwYNUUgVHhr-xLO9feW2rWGeL78Aks5t94x-gaJpZM4UrTn9>
.
|
Resolves #732