Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expansion of background contains errors #8

Open
mblakele opened this issue Feb 16, 2016 · 4 comments
Open

expansion of background contains errors #8

mblakele opened this issue Feb 16, 2016 · 4 comments

Comments

@mblakele
Copy link

var sc = require("shortcss")
sc.expand('background', 'no-repeat center/125% url(fubar.jpg)')

Expected:

background-image: url(fubar.jpg)
background-position: "center"
background-repeat: "no-repeat"
background-size: "125%"

Unexpected:

background-attachment: "no-repeat"
background-clip: "center/125%"
background-color: "center/125%"
background-image: "no-repeat"
background-origin: "no-repeat"
background-position: "center/125%"
background-repeat: "center/125%"
background-size: "url(fubar.jpg)"

Seems like the values are going into the wrong slots, and there's no handling of position and size.

@tyv
Copy link

tyv commented Nov 21, 2016

expand('background', '#ffffff url('img_tree.png') no-repeat fixed right top')

returns

{
  "background-attachment": "#ffffff",
  "background-clip": "top",
  "background-color": "url('img_tree.png')",
  "background-image": "#ffffff",
  "background-origin": "right",
  "background-position": "url('img_tree.png')",
  "background-repeat": "fixed",
  "background-size": "no-repeat"
}

@tyv
Copy link

tyv commented Nov 26, 2016

i can take this issue

@tyv
Copy link

tyv commented Nov 29, 2016

it seems that background require map of possible values corresponded to the expanded property

@tyv
Copy link

tyv commented Nov 29, 2016

@awinogradov there are 2 options to fix that correctly I see:

  1. if you use library in browser runtime it is easy via getComputedStyle and with expandAsArray (which is okay for reasons I am here)
  2. use library (almost the css parser) to parse compacted value correctly. For example background: it has / and between position and size and also it could contain clip and origin which values are border-box|padding-box and the order is important in that case, but order of other components aren't.. so many small issues. I suggest to use https://github.com/ben-eb/css-values for this and can create lib for expanding values if you agree to extend expand() function with it, it will bring an amount of bytes :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants