infernojs / babel-plugin-inferno

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

Fix SVG elments not getting flagged as such #50 #51

Closed BrinaryG closed 6 years ago

BrinaryG commented 6 years ago

50

Havunen commented 6 years ago

Hi @BinaryG awesome stuff! Where did you get the list of elements. Just wondering how to best keep it updated

BrinaryG commented 6 years ago

Hi @Havunen

I pulled the list from MDN

using this in the console: $('.index code').toArray().map(c => c.innerText.replace('<','').replace('>','')).reduce( (acc, c) => { acc.push(c); return acc; },[]).map(c =>${c}: VNodeFlags.SvgElement).join(',\n')

I then filtered out any conflicts with HTML elements from here

using this in the console:

$('[data-default-state="open"] code').toArray().map(c => c.innerText.replace('<','').replace('>',''))

which left me with 6 elements that are both HTML and SVG tag names:

["a", "font", "image", "script", "style", "title"]

I am not sure this is the best way to handle this so I removed them from the VNodeTypes list maybe it would be better to pass a flag through the transpiler if we are inside an "svg" element and flag all children as such, this would obviously be a bigger change but may be more robust, let me know if this is the direction you would like to go and I will try to dedicate some time to it.

Let me know if anything I have done is incorrect as this is my first PR :)

Thanks

Havunen commented 6 years ago

Those extra elements should be handled in Inferno, it passes down isSVG property so I think its fine.

Yeah, this PR looks good to me. Lets merge it! Thanks for your contribution @BrinaryG !