diff options
| author | Vojta Jina | 2012-04-02 12:26:57 -0700 |
|---|---|---|
| committer | Vojta Jina | 2012-04-03 10:10:44 -0700 |
| commit | a22e0699bef61a7083b0b628fb6043531c0ca1c0 (patch) | |
| tree | c5ca4dfa9fbef8804d3f623379dac1c0b47d7b2e /src/ng/sniffer.js | |
| parent | 28ff7c3a66fbd770515273c7ca2fcb9cd936b50e (diff) | |
| download | angular.js-a22e0699bef61a7083b0b628fb6043531c0ca1c0.tar.bz2 | |
feat($sniffer): add hasEvent method for sniffing events
Skip changelog
Diffstat (limited to 'src/ng/sniffer.js')
| -rw-r--r-- | src/ng/sniffer.js | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/ng/sniffer.js b/src/ng/sniffer.js index eebb2903..3249b816 100644 --- a/src/ng/sniffer.js +++ b/src/ng/sniffer.js @@ -12,13 +12,23 @@ * @description * This is very simple implementation of testing browser's features. */ -function $SnifferProvider(){ - this.$get = ['$window', function($window){ +function $SnifferProvider() { + this.$get = ['$window', function($window) { + var eventSupport = {}; + return { history: !!($window.history && $window.history.pushState), hashchange: 'onhashchange' in $window && // IE8 compatible mode lies - (!$window.document.documentMode || $window.document.documentMode > 7) + (!$window.document.documentMode || $window.document.documentMode > 7), + hasEvent: function(event) { + if (isUndefined(eventSupport[event])) { + var divElm = $window.document.createElement('div'); + eventSupport[event] = 'on' + event in divElm; + } + + return eventSupport[event]; + } }; }]; } |
