mzsanford/R2rb

Invalid background-position value created

Closed this issue · 3 comments

I've been working on RTL support on OpenStreetMap, and I was puzzled to see a case on their About page where one sprite-icon is visible, but the others are not (you can see this if your browser is set to prefer Arabic).

The visible sprite has the CSS set background-position: -45px -160px

The invisible sprites have CSS values set to background-position: right 0px -80px which is not accepted by Firefox or Chrome. I think that background-position: right {x} top {y} would be valid. The one visible sprite has a negative x-value, so your regex isn't noticing it.

In my case I am looking at sprites, so I would rather not have them shifted left/right. I'll ask OSM to use 0 instead of 0px for now, but what would be a good long-term solution for other people using sprites?

R2 makes every attempt to swap everything. It seems like in this sprite case you would like to not flip the sprite definition. Is that correct? One approach to that would be to add some method of disabling R2 for a given CSS block, like https://github.com/mzsanford/R2rb/compare/osm_sprite. If that would help I'll merge it

@mzsanford 👍 I like this idea. I don't know if it will get accepted on the OSM side, but it would resolve our problem

Merged and release v0.2.7 with the option to ignore.