justin-schroeder / arrow-js

Reactivity without the framework

Home Page:https://arrow-js.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Static string cleared from attribute

zeenau opened this issue · comments

Example:

const data = reactive({
  class:'css'
})
<li class="prefix-${() => data.class}-postfix" >Title</li>

renders to:

<li class="css" >Title</li>

instead of:

<li class="prefix-css-postfix" >Title</li>

notice "prefix/postfix" removed from the class attribute.

I understand that this can be refactored (to include all inside the function) but I'd expect static string before/after observable to be left unchanged.

This example is oversimplified but the idea is that template holds static values (to render even without dynamic part being set).

Yeah, I understand that it may seem intuitive for it to work that way, but it does not. Attributes are all or nothing — similar to many reactive frameworks where the expression is the value of the argument (in the <div :class="expHere">). It would be quite a lot more "expensive" in compute and memory to allow this types of arbitrary concatenation. If you want to perform string interpolation, just include that as the output of your fn.

Thanks for checking out arrow though!