[imps] data-* vs x-vendor-* attributes

Ian Hickson ian at hixie.ch
Sun Feb 28 10:26:52 PST 2016


What your describe is exactly a vendor-specific proprietary user agent
extension.

data-* would be inappropriate as that is for authors.

I think my recommendation would be to have one private format for editing
that has this information (could just be XML), and then export to HTML
without this information.

On Sun, Feb 28, 2016, 08:42 Jarek Foksa <jarek at boxy-svg.com> wrote:

> I'm building an SVG editor that allows users to save SVG documents using
> either XML or HTML 5 serialization.
>
> In order to preserve editing capabilities I need to store app-specific
> data as content attributes. For example, when user draws a star path, I
> want to preserve the information about the number of arms, the inner radius
> and the outer radius of the star.
>
> When using XML serialization, the obvious solution is to use custom
> namespace:
>
>   <svg viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg" xmlns:bx="
> http://www.boxy-svg.com/bx">
>     <path bx:shape="star" bx:arms="6" bx:r1="10" bx:r2="20" d="...">
>   </svg>
>
> However, I'n not sure how the corresponding markup should look like when
> using HTML 5 serialization. Should I use data-* attributes?
>
>   <svg viewBox="0 0 500 500">
>     <path data-shape="star" data-arms="6" data-r1="10" data-r2="20"
> d="...">
>   </svg>
>
> ... or data-vendor-* attributes?
>
>   <svg viewBox="0 0 500 500">
>     <path data-bx-shape="star" data-bx-arms="6" data-bx-r1="10"
> data-bx-r2="20" d="...">
>   </svg>
>
> ... or x-vendor-* attributes?
>
>   <svg viewBox="0 0 500 500">
>     <path x-bx-shape="star" x-bx-arms="6" x-bx-r1="10" x-bx-r2="20"
> d="...">
>   </svg>
>
> The data-* approach is very likely going to cause clashes when the file is
> opened with another editor.
>
> The data-vendor-* approach does not seem to be mentioned in the spec.
>
> The x-vendor-* approach seems to be what the HTML spec recommends, but I'm
> not entirely sure whether my usage falls under the category of
> "vendor-specific proprietary user agent extension". Also, the x-vendor-*
> attributes are not mentioned in the current SVG 2 draft.
>
> _______________________________________________
> Implementors mailing list
> Implementors at lists.whatwg.org
> http://lists.whatwg.org/listinfo.cgi/implementors-whatwg.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/implementors-whatwg.org/attachments/20160228/7933d217/attachment.htm>


More information about the Implementors mailing list