-
Notifications
You must be signed in to change notification settings - Fork 12
Adds option that allows passing component tags as reference #43
Conversation
@@ -18,5 +18,6 @@ export default function elementCloseCall(t, path, plugin) { | |||
} | |||
} | |||
|
|||
return toFunctionCall(t, iDOMMethod("elementClose", plugin), [toReference(t, node.name)]); | |||
const isComponent = /^[A-Z]/.test(node.name.name); |
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 create a helper specifically for this? isComponent
sounds perfect.
Yay contributions! I think the only thing missing is a test for |
Thanks for considering and reviewing this! I've added the changes you've requested, so let me know if they're what you meant :) |
@@ -4,7 +4,7 @@ import toReference from "./ast/to-reference"; | |||
import iDOMMethod from "./idom-method"; | |||
|
|||
// Returns the closing element's function call. | |||
export default function elementCloseCall(t, path, plugin) { | |||
export default function elementCloseCall(t, path, plugin, { components, isComponent }) { |
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.
Almost, I was aiming for a isComponent
helper function like iDOMMethod
and similar:
# helpers/is-component.js
export default function isComponent(tag) {
return /^[A-Z]/.test(tag);
}
# helpers/element-close-call.js
import isComponent from './is-component';
//...
112f282
to
9ce95f8
Compare
Makes sense, done :) |
Thanks! |
Thank you! Could you also release an npm version with these changes so I can use them instead of my fork? :) |
I'll try to get to that tomorrow. |
Published v3.1.0 |
@mairatma What kind of extra code is needed to be able to use this? |
@anilanar you just need to make sure that you're using |
I'm not sure if this is something that you'd want to merge, but I added an option on my fork of babel-incremental-dom to enable passing upper case tags by reference to incremental dom calls, even though that doesn't work without extra code. I need this for a project I'm working on, where we already handle this case internally, but needed the compiler to work as expected.
I saw that you already have an issue (#9) for working on this feature, but since it seems to waiting for some changes on incremental dom's side I think this option I've added could be useful for some people, so sending it in case you agree as well :)