infernojs / babel-plugin-inferno

Transforms JSX to InfernoJS vNodes
MIT License
79 stars 26 forks source link

undefined instead of fragment #1

Closed NekR closed 8 years ago

NekR commented 9 years ago

Templaes are evaluated into this. Note undefined.appendChild(...).

function tpl1272327436(fragment) {
    var root = Inferno.template.createElement("div");
    fragment.dom = root
    var child_0_root = Inferno.template.createElement("div");
    undefined.appendChild(child_0_root);
    var child_1_0 = Inferno.template.createElement("span");
    child_0_root.appendChild(child_1_0);

    if (typeof fragment.templateValues[0] !== "object") {
        child_1_0.textContent = fragment.templateValues[0];
        fragment.templateTypes[0] = Inferno.FragmentValueTypes.TEXT;
    } else {
        fragment.templateTypes[0] = (fragment.templateValues[0].constructor === Array ? Inferno.FragmentValueTypes.LIST : Inferno.FragmentValueTypes.FRAGMENT);
    }

    fragment.templateElements[0] = child_1_0;
    var child_1_root = Inferno.template.createElement("h1");
    undefined.appendChild(child_1_root);
    child_1_root.textContent = "Hello world!";
}
trueadm commented 9 years ago

@NekR yeah, this is still very much a WIP, still huge amounts to do :) the bit you've found simply hasn't been done yet/

NekR commented 9 years ago

@trueadm just decided to report it. I know it's WIP. Also it's a bit hard to review it because I do not know which output is correct for Inferno. But one more thing which noticed is that your are generating a lot of code for the template. So it might be better to generate some helpers first, especially if there is potential of those code to repeat many times.

trueadm commented 9 years ago

@NekR that's where things slow down. The idea is that templates can be either using the Inferno functional API or the imperative API. The imperative API means more code but is vastly faster, and thus why i opted to go this route (it's what makes Inferno fast in all the benchmarks).

NekR commented 9 years ago

@trueadm this makes sense. But helpers should be also optimized if used many times. Does small helpers really slow down everything?