Skip to content

Instantly share code, notes, and snippets.

@marshall007
Last active August 29, 2015 14:13
Show Gist options
  • Save marshall007/6866ad54cbe1cff5ed22 to your computer and use it in GitHub Desktop.
Save marshall007/6866ad54cbe1cff5ed22 to your computer and use it in GitHub Desktop.
Execute Selectivizr polyfills dynamically on every `$digest` cycle
# NWMatcher.js
# Load only in IE8-
# //cdnjs.cloudflare.com/ajax/libs/nwmatcher/1.2.5/nwmatcher.js
app.run [
'$rootScope', '$rootElement', '$timeout'
($rootScope, $rootElement, $timeout) ->
return if not NW? # don't add any watchers if our browser doesn't suck
selectivize = ->
elements = NW.Dom.select ':last-child', $rootElement[0]
angular.forEach elements, (el) ->
angular.element(el).addClass 'last-child'
execute = null
# watch fires on every $digest
$rootScope.$watch ->
$timeout.cancel execute if execute
execute = $timeout selectivize, 0, false
return true
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment