Last active
August 29, 2015 14:13
-
-
Save marshall007/6866ad54cbe1cff5ed22 to your computer and use it in GitHub Desktop.
Execute Selectivizr polyfills dynamically on every `$digest` cycle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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