Selaa lähdekoodia

Improve css gradients feature detection

Thibaut 11 vuotta sitten
vanhempi
commit
20b1c02a3a
1 muutettua tiedostoa jossa 6 lisäystä ja 1 poistoa
  1. 6 1
      assets/javascripts/app/app.coffee

+ 6 - 1
assets/javascripts/app/app.coffee

@@ -154,7 +154,7 @@
         classList:          !!document.body.classList
         insertAdjacentHTML: !!document.body.insertAdjacentHTML
         defaultPrevented:     document.createEvent('CustomEvent').defaultPrevented is false
-        cssGradients:         getComputedStyle(document.querySelector('._header')).backgroundImage isnt 'none'
+        cssGradients:         supportsCssGradients()
 
       for key, value of features when not value
         Raven.captureMessage "unsupported/#{key}"
@@ -178,4 +178,9 @@
   isInvalidLocation: ->
     @config.env is 'production' and location.host.indexOf(app.config.production_host) isnt 0
 
+supportsCssGradients = ->
+  el = document.createElement('div')
+  el.style.cssText = "background-image: -webkit-linear-gradient(top, #000, #fff); background-image: linear-gradient(to top, #000, #fff);"
+  el.style.backgroundImage.indexOf('gradient') >= 0
+
 $.extend app, Events