mavo icon indicating copy to clipboard operation
mavo copied to clipboard

Provide a way for attributes to contain expressions without triggering browser errors or false loading

Open LeaVerou opened this issue 6 years ago • 0 comments

While allowing expressions in attributes is certainly convenient, in certain cases it has annoying side effects. For example, putting expressions in img/@src fires a pointless HTTP request, before the expression has a chance to resolve. Also, putting expressions in attributes that accept restricted values (e.g. numbers) results in pointless errors. The SVG Path builder demo is a great example of this: image

We should support an alternative syntax for these cases. E.g. (using src as an example) something like mv-attr-src, or mv-@src or even just @src (alternative suggestions welcome!) This has the added benefit of allowing fallbacks by just providing a value on the actual attribute. This will also make Viviz's use case easier, since it will enable it to create SVGs that can be read by any SVG editor but will still have their expressions. If we leave the original attribute (mv-attr-src or whatever) intact, this can also greatly help SSR (cc @betaveros who may find this interesting).

Whoever implements this, one caveat: <img property="prop" mv-attr-src="[foo]" /> should still be read-only. Depending on how this is implemented, it may or may not require changes in Mavo.Primitive. Assuming the attribute is rewritten in Mavo.DOMExpression (like how mv-value works), then it should work automatically.

LeaVerou avatar Feb 11 '19 01:02 LeaVerou