starfederation / datastar-restructure-interim

MIT License
9 stars 4 forks source link

Improve signals regexp #28

Open bencroker opened 1 week ago

bencroker commented 1 week ago

Calling $signal.toUpperCase() works, whereas $signal.length errors.

Error: ctx.store().signal.length.value is undefined

It would be great if we could find a way to make it work, rather than forcing people to write it as ($signal).length.

Perhaps we could backtrack from ctx.store().signal.length.value to ctx.store().signal.value if the former is undefined?

I realise this adds extra logic, but it’s in the name of better UX.

https://github.com/starfederation/datastar/blob/d185a5a080ac266d4131426699366dd7ddbaccba/code/ts/library/src/plugins/official/preprocessors/core/signals.ts#L8

delaneyj commented 1 week ago

It's possible we just need to be consistent with the rule cause it'll have to live outside of the regexp... in fact it's gonna have to build up a chain of regexp (which will be slow)