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

Jarek Foksa jarek at boxy-svg.com
Sun Feb 28 14:47:15 PST 2016


Thanks for response.

I asked a similar question on the SVG WG issue tracker [1], but there is a disagreement whether data specific to given authoring tool should be treated as author data or vendor data.

I'm still not sure if this is the best approach, but I'm going to play with the idea of allowing the user to decide whether to strip the vendor data (all x-* attributes) and/or author data (all data-* attributes) when saving the file. There are situations where user might prefer to preserve editability over conformance and vice versa.

[1] https://github.com/w3c/svgwg/issues/53

> On 2016-02-28, at 19:26, Ian Hickson <ian at hixie.ch> wrote:
> 
> 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



More information about the Implementors mailing list