infernojs / babel-plugin-inferno

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

Element with index attribute has broken attrs field when compiled #13

Closed jpdutoit closed 8 years ago

jpdutoit commented 8 years ago
<div index="text"></div>

compiles to:

({
    tag: "div",
    attrs: vtext,
    dom: null
});
jpdutoit commented 8 years ago

This was using the latest spike branch.

JustinWilabyPrecor commented 8 years ago
<div index="text"></div>

index="text" is invalid html. Did you mean data-index="text"?

jpdutoit commented 8 years ago

It also happens when passing a parameter called index to a component:

 <Component index="text"/>
justinwilaby commented 8 years ago

@jpdutoit - Can you confirm that #14 fixes the issue?

jpdutoit commented 8 years ago

Why keep the behaviour for number values? I couldn't see this documented anywhere.

Will test it as soon as i get a chance.

On Wednesday, 23 March 2016, Justin Wilaby notifications@github.com wrote:

@jpdutoit https://github.com/jpdutoit - Can you confirm that #14 https://github.com/trueadm/babel-plugin-inferno/pull/14 fixes the issue?

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/trueadm/babel-plugin-inferno/issues/13#issuecomment-200461919

justinwilaby commented 8 years ago

If you look at how Inferno Works, the schema is created with arguments whose name corresponds to the index of the template function params prepended with "v" I don't think this is necessarily relevant for the spike branch since it seems there are changes that may obviate this but it makes sense in the master and dev branches of inferno.

<div selected={this.shouldBeSelected}></div>

Transpiles to:

tpl3295379617 = Inferno.createTemplate(function (v0) {
    return {
        tag: 'div',
        attrs: {
            selected: v0
        }
    };
});

function render(){
    return tpl3295379617(this.shouldBeSelected);
}

Where v0 represents the first argument in the template's function.

justinwilaby commented 8 years ago

I should add that adding the index on an attribute's schema descriptor is here

jpdutoit commented 8 years ago

Yeah, createTemplate does not exist anymore in spike, so I thought perhaps that part was a remnant of earlier code that has not been removed yet. Unless it has some purpose...

On Wednesday, 23 March 2016, Justin Wilaby notifications@github.com wrote:

I should add that adding the index on an attribute's schema descriptor is here https://github.com/trueadm/babel-plugin-inferno/blob/master/lib/index.js#L66

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/trueadm/babel-plugin-inferno/issues/13#issuecomment-200521662

trueadm commented 8 years ago

createTemplate and schemas have been removed in the spike branch. They are clunky in behaviour and made the codebase twice the size it should be with no gain in performance in most use-cases. I'm hoping to promote spike to master by Friday (in time for Easter) for both Inferno and this Babel plugin.

I've just got to sort out a few issues. If anyone is not on Slack, let me know so I can send you an invite. I'd love as much interaction before promoting to master, so we can squash the last few big bugs.

trueadm commented 8 years ago

Closing as this is no longer an issue.