mavo icon indicating copy to clipboard operation
mavo copied to clipboard

Use custom element for helper variables instead of <meta>

Open LeaVerou opened this issue 4 years ago • 8 comments

<meta> does not work in SVG contexts, it's recognized as an HTML element and kicked out of the SVG. We should use a <mv-*> custom element instead (which can also have a more descriptive name and syntax).

Suggestions?

LeaVerou avatar Jan 14 '21 11:01 LeaVerou

What do you think of using <mv-property> as such an element? We already use an attribute with the same name, so, to my mind, it's natural to stick to it since we element we are going to add will have the same semantic—declaring a property/collection. So we don't need to learn anything new. Is it a bad practice?

DmitrySharabin avatar Jan 14 '21 14:01 DmitrySharabin

Always think of example code when proposing names or syntaxes. With <mv-property> you end up with things like <mv-property property="foo">bar</mv-property>. Does this read nicely? I think it's too much repetition.

LeaVerou avatar Jan 14 '21 14:01 LeaVerou

What about <mv-data>?

<mv-data property="foo">bar</mv-data>

LeaVerou avatar Jan 14 '21 14:01 LeaVerou

Always think of example code when proposing names or syntaxes.

My bad. Sorry.

I was thinking of something like: <mv-property name="foo" value="bar" /> or <mv-property name="foo">bar</mv-property>

What about ?

I'm OK with this too. Will it be hidden out of the edit mode like meta?

DmitrySharabin avatar Jan 14 '21 14:01 DmitrySharabin

Once we have this custom property could it also be used in other contexts where <meta> gets kicked out, e.g. inside a <table>?

karger avatar Jan 14 '21 14:01 karger

Always think of example code when proposing names or syntaxes.

My bad. Sorry.

No need!

I was thinking of something like: <mv-property name="foo" value="bar" /> or <mv-property name="foo">bar</mv-property>

These are still regular properties, they need to use the same attributes. Also custom elements cannot be self-closing (yet)

I'm OK with this too.

I just realized, this would be a problem if we adopt the mv-data attribute proposed in #643 🤔

Will it be hidden out of the edit mode like meta? Yes.

Once we have this custom property could it also be used in other contexts where <meta> gets kicked out, e.g. inside a <table>?

Oh good point. No, it appears to be hoisted still. <template> on the other hand is not (I also checked with <select>). So perhaps we can (ab)use <template> for this?

Inspect the DOM here: https://dabblet.com/gist/47fe643dc2dfd0118cf2e83e55e9af15

LeaVerou avatar Jan 14 '21 14:01 LeaVerou

oy. is template the only element that doesn't get hoisted?

karger avatar Jan 14 '21 15:01 karger

That I know of :/

LeaVerou avatar Jan 14 '21 15:01 LeaVerou