ryansolid / dom-expressions

A Fine-Grained Runtime for Performant DOM Rendering
MIT License
887 stars 127 forks source link

Reasoning for string template literals #58

Closed nicketson closed 3 years ago

nicketson commented 3 years ago

Is there a reason that template literals are generated here instead of regular strings? Unless I am missing something there are never any expressions in the strings.

ryansolid commented 3 years ago

Can you be more more specific on where you mean by "here"?

nicketson commented 3 years ago

Oops, forgot to include this: https://github.com/ryansolid/dom-expressions/blob/master/packages/babel-plugin-jsx-dom-expressions/src/dom/template.js#L50

ryansolid commented 3 years ago

You will probably think this is silly but just avoided having extra escape characters around attribute quotes. I haven't witnessed any perf issues with template literals (tagged template literals is another thing). Although to be fair I only ever tested this with interpolation so it is possible simple string creation is different but it reads nicer and is fewer characters.