-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
Allow tag selectors in render functions #4016
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
Conversation
This allows tags such as 'section.active.admin@intro', which would yield <section class='active admin' id='intro'>
When checking for undefined components, use 'undefined' instead of a tag with an empty string, since an empty string will now failover to a <div> tag. This may sound awkward, but an empty string tag previously could arguably be considered an error/invalid. By allowing this to failover to a <div> tag, it makes constructs such as '.active@menu' to naturally be resolved as <div class="active" id="menu">, etc.
If I get this right, I don't think this belongs to the core. Maybe a custom |
A custom render function would work. Is there a way to have a hook inside of createElement that is able to invoke this code if specified? |
Yes you can. Vue.mixin({
beforeMount() {
this.$createElement = customCreateElement
}
})
Vue.prototype._h = customCreateElement This should works. The first statement is for render function, the second statement is for compiled template . POC https://jsfiddle.net/v368d4g3/3/ Caveats: implementation details are liable to change |
Oh, man! That's great. Is this a one-liner type of tweak that we could put in our top-level app and everything would inherit? That would make it super easy. Is there another library, module, or mixin (or whatever else) that could be used as an example for this type of feature? |
Yes, if I read the code correct. Place it in your entry file and most things will be fine. (
I don't know. I think this is too hacky to be included in a project's README... |
@phanan - Is there already a way to support such as custom render function as a Vue plugin? |
As it has turned into a discussion, I'd suggest opening a thread on the forum instead. |
This allows tags such as
section.active.admin@intro
, which would yield<section class='active admin' id='intro'>
.Allowing these types of selectors, when used in combination with another tiny enhancement (https://github.com/shreeve/coffeescript/pull/1) to
CoffeeScript
allows us to write nativeCoffeeScript
that looks a lot likeJSX
, but is actually full fledgedCoffeeScript
. Here's an example of something we're working on (a work in progress, but coming along!):