()
| 1999 | |
| 2000 | var bindJQueryFired = false; |
| 2001 | function bindJQuery() { |
| 2002 | var originalCleanData; |
| 2003 | |
| 2004 | if (bindJQueryFired) { |
| 2005 | return; |
| 2006 | } |
| 2007 | |
| 2008 | // bind to jQuery if present; |
| 2009 | var jqName = jq(); |
| 2010 | jQuery = isUndefined(jqName) ? window.jQuery : // use jQuery (if present) |
| 2011 | !jqName ? undefined : // use jqLite |
| 2012 | window[jqName]; // use jQuery specified by `ngJq` |
| 2013 | |
| 2014 | // Use jQuery if it exists with proper functionality, otherwise default to us. |
| 2015 | // AngularJS 1.2+ requires jQuery 1.7+ for on()/off() support. |
| 2016 | // AngularJS 1.3+ technically requires at least jQuery 2.1+ but it may work with older |
| 2017 | // versions. It will not work for sure with jQuery <1.7, though. |
| 2018 | if (jQuery && jQuery.fn.on) { |
| 2019 | jqLite = jQuery; |
| 2020 | extend(jQuery.fn, { |
| 2021 | scope: JQLitePrototype.scope, |
| 2022 | isolateScope: JQLitePrototype.isolateScope, |
| 2023 | controller: /** @type {?} */ (JQLitePrototype).controller, |
| 2024 | injector: JQLitePrototype.injector, |
| 2025 | inheritedData: JQLitePrototype.inheritedData |
| 2026 | }); |
| 2027 | } else { |
| 2028 | jqLite = JQLite; |
| 2029 | } |
| 2030 | |
| 2031 | // All nodes removed from the DOM via various jqLite/jQuery APIs like .remove() |
| 2032 | // are passed through jqLite/jQuery.cleanData. Monkey-patch this method to fire |
| 2033 | // the $destroy event on all removed nodes. |
| 2034 | originalCleanData = jqLite.cleanData; |
| 2035 | jqLite.cleanData = function(elems) { |
| 2036 | var events; |
| 2037 | for (var i = 0, elem; (elem = elems[i]) != null; i++) { |
| 2038 | events = jqLite._data(elem).events; |
| 2039 | if (events && events.$destroy) { |
| 2040 | jqLite(elem).triggerHandler('$destroy'); |
| 2041 | } |
| 2042 | } |
| 2043 | originalCleanData(elems); |
| 2044 | }; |
| 2045 | |
| 2046 | angular.element = jqLite; |
| 2047 | |
| 2048 | // Prevent double-proxying. |
| 2049 | bindJQueryFired = true; |
| 2050 | } |
| 2051 | |
| 2052 | /** |
| 2053 | * throw error if the argument is falsy. |
no test coverage detected