medusa-ui/medusa

Variables in functions don't work

Closed this issue · 3 comments

Not sure if they should, really? But now they give an odd error.

If we do make it work, this cannot be a pure 'replace once' option. We would have to give the element using the param in a function a unique id, then store the id in a registry + the function name. Then check for every variable change if the registry contains a reference to the variable and if so, replace the function for all elements with said id.

Example:

<p id="val1">Value1: [$value1]</p>
<p id="passed-val">Passed value: [$passed-value]</p>
<button id="pass" m-click="passValue($value1)">Pass value from parameter</button>

If we do make this work, as opposed to just throw a better error - we should make sure the value of the variable can be a non-latin character. For example, you can use Medusa in Korean: 메두사

This works if $value is between single quotes, and the value can be contain non utf-8 chars like 메두사

<button id="pass" m-click="passValue('$value1')">Pass value from parameter</button>

But maybe I do not understand the problem correctly?

Reworked in 3aa1898