Tobias Uhlig
1 min readApr 20, 2021

--

I have been thinking about this more. A lot.

While we can not convert a template literal to a string, we definitely can convert a function to a string.

bind: {

text: function(data) {return `hello ${data.foo}`;}

}

bind: {

text: data => `hello ${data.foo}`

}

let foo = function(data) {return `hello ${data}`;};

foo.toString()

// logs “function(data) {return `hello ${data}`;}"

let bar = data => `hello2 ${data}`;

bar.toString()

// logs “data => `hello2 ${data}`”

this is definitely good enough for a regex parsing and makes a feature request for a string to literal converter obsolete.

since we most likely want the scope of the binding formatters to be inside the closest view model, using an arrow operator does not really make sense. This would scope the function to the component instance.

you could use it, but then we have a double fn binding, which is a bit slower.

I will work on a PoC now to check how it works out. You could still make formatters editable for app users using the new Function() hack yourself, but this security issue won't affect all other apps.

--

--

No responses yet