threepointone/glamor

Edge cases

Closed this issue · 2 comments

I've tested some edge cases and here is what we have currently:

style({})
// returns 
{ 'data-css-120drhm': '*' }
// inserts to stylesheet
'[data-css-120drhm] { null }'

select(' a', {})
// returns 
{ 'data-css-p8xeo9': '*' }
// inserts
'[data-css-p8xeo9] a { null }'

merge()
// returns 
{ 'data-css-120drhm': '[]' }
// inserts nothing to stylesheet

merge({})
// returns 
{ 'data-css-11ra3p3': '[{:}]' }
// inserts nothing to stylesheet

media('()', {})
// returns
{ 'data-css-11qittp': '*mq({:})' }
// inserts to stylesheet 
`
@media (){
      [data-css-11qittp] { null }
}`

media('()')
// returns 
{ 'data-css-1853dek': '*mq()' }
// inserts nothing to stylesheet

keyframes('bounce', {})
// returns 
'bounce_nc5hzc'
// inserts to stylesheet 
`
@-webkit-keyframes bounce_nc5hzc { }
@-moz-keyframes bounce_nc5hzc { }
@-o-keyframes bounce_nc5hzc { }
@keyframes bounce_nc5hzc { }
`

fontFace({})
// returns
undefined 
// inserts nothing to stylesheet

fontFace({fontStyle: 'normal'})
// returns
undefined 
// inserts to stylesheet
'@font-face { font-style:normal;}'

cssFor()
// returns 
''
// inserts nothing to stylesheet

attribsFor()
// returns 
''
// inserts nothing to stylesheet

I suggest:

  1. For style/select/merge/media invocations from above return empty object. Add nothing to stylesheet.
  2. Keyframes - keep as is
  3. fontFace - current behaviour looks bad, but I'm not sure how to fix it.
  4. cssFor and attribsFor are fine

Thanks for diving into this!

Working on it as it's closely related to #41