albell / parse-srcset

A spec-conformant JavaScript parser for the HTML5 srcset attribute

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

x descriptor is added as 'd'

aFarkas opened this issue · comments

The inline documentation says that the `x' descriptor is exposed a 'x', but instead it is exposed as 'd'.

I would prefer, if it would be the x key, because every candidate has a computable pixel density. So the d can be used to bring sizes and w descriptor together.

Oops, you're right, it's inconsistent.

I used w, d, and h in the code because they are all the first letters of the properties described: width, density and height. I am reluctant to break that parallelism. Especially because "x" usually means horizontal dimension, and it's liable to be misunderstood by other people. I'm open to discussion, but I think I prefer how it is. I would prefer to correct my inline documentation.

I also think the English word "density" should be used only to refer to a ratio. E.g. pixels per inch, device pixels per CSS pixel. That sort of thing. I think what you are referring to, the value computed by sizes and w (or h) descriptors, is a pixel dimension, not a pixel density. I don't mean to be a pedant, but it will be good for readability later on. As you probably notice, I'm not afraid of long variable names, as long as they minify :)

Let me know your thoughts.

I don't have a strong opinion. Then just correct your documentation ;-).