Creating wrapper elements with tagged templates #385
Replies: 3 comments
-
@auniverseaway responded withI think this is good for certain use cases, and not ideal for others. If you have existing DOM you need to blend into this, you're stuck doing something like The other piece is that if you need to bind events or add attributes due to state, you are querying the DOM again after you inject this raw HTML. I typically like to have a single code path for accomplishing the same task, which is why I tend to use |
Beta Was this translation helpful? Give feedback.
-
@overmyheadandbody responded withFollowing up on this, I came up with an approach that should satisfy our desired way of handling templates but also the valid concerns from the Milo side. Below you'll find a quick example of the current way of building templates compared to our proposal. Current
Proposal
Advantages
POCYou can find a barebones version of the method here - https://codepen.io/ramuntea/pen/zYabPJR?editors=1010 FeedbackDo you see this is a good path forward, @auniverseaway & @chrischrischris? I'm asking because we'll be refactoring the gnav code in a feature branch and likely a slightly different folder, so we don't bump into merge/rebase issues as multiple engineers add conflicting logic. If you think this templating approach would be valuable for the whole Milo project, I can create a PR and add my |
Beta Was this translation helpful? Give feedback.
-
@auniverseaway responded withThanks @overmyheadandbody! This is clever! Couple comments:
gnav and footer are our #1 and #2 contributors to TBT that are under our control. By adding more work to the CPU, I do worry we are not moving in the right direction to get our TBT down. The thing I always say is that developers should be considered last when it comes to priorities...
From what I'm hearing above, this conversation is about "readability" above all. Which is a developer problem. If you want to prototype your idea with gnav and see if you find it materially better, I'm 100% supportive. I don't think I'm ready to ship the above until we see it in use and we collectively agree it's a better solution for everyone. |
Beta Was this translation helpful? Give feedback.
-
Moving this conversation started by @mokimo to the public forum. This is a copy of the thread before my response:
Description
We are looking for a more standardised way of creating wrapper elements for the GNAV. IMO this is a good candidate for a broader audience as milo utility function/paradigm to use.
The current way
How things are currently working is creating a lot of tags via Javascript in the GNAV
The proposed way
To separate the JS and HTML where possible, we are proposing using a function or tagged templates to generate DOM-Fragments.
Based on @chrischrischris feedback an interesting approach could be tagged templates instead of a function so that it can be used as
h'<stuff></here>'
More input appreciated!
Beta Was this translation helpful? Give feedback.
All reactions