ryansolid / dom-expressions

A Fine-Grained Runtime for Performant DOM Rendering
MIT License
863 stars 125 forks source link

Ability to set certain properties / attributes as always static #343

Open chiefcll opened 3 weeks ago

chiefcll commented 3 weeks ago

Using the universal renderer - I have a property style for nodes which is never dynamic. Is there a way to list certain props / attributes as never dynamic to avoid the user needing to add /@once/ marker?

I see style might do something like this already:

} else if (
          config.effectWrapper &&
          (isDynamic(attribute.get("value").get("expression"), {
            checkMember: true
          }) ||
            ((key === "classList" || key === "style") &&
              !attribute.get("value").get("expression").evaluate().confident))
        ) {
ryansolid commented 5 days ago

We do a trick where we can evaluate expressions and hoist them out. But that only works within module scope and basically on constants... classList and Style are a bit special cased because their dynamicism is broken down to object properties, but I don't have a generic way to do that. In general I could see the potential of adding a list for saying static I suppose, but we don't have that concept in the DOM.