Replies: 1 comment
-
I think both are fine. Both work and I think depending on your use case, you can use either.
When you use innerHTML, you then have to use querySelector to attach events and I felt it was better to have a small abstraction around document.createElement rather than building DOM up as strings, only to then query for what you had just created. We had this discussion at lunch the other day, but there are other approaches to abstract createElement and everyone feels like their approach is the, "the best." From a platform support perspective, we felt like having something that was terse, performant, and could be understood in under 120 seconds was a better alternative to something more declarative, but required more training or didn't meet our performance goals. Even with Lit or Preact's declarative html syntax, there's a bit of learning curve and you don't have as fine grained await control without learning even more custom syntax like until. |
Beta Was this translation helpful? Give feedback.
-
Which one of these two approaches will be most favorable? createTag() vs Template Literal:
// option 1
// option 2
Beta Was this translation helpful? Give feedback.
All reactions