From a004d487c4bb48b2bec19b60bc5ddc5244029be5 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Fri, 4 Feb 2011 16:42:21 -0800 Subject: allow jquery to be declared after angular in the script loading order --- src/Angular.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src/Angular.js') diff --git a/src/Angular.js b/src/Angular.js index 4187e9ad..b856aa24 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -83,17 +83,16 @@ var _undefined = undefined, PRIORITY_LAST = 99999, PRIORITY = {'FIRST': PRIORITY_FIRST, 'LAST': PRIORITY_LAST, 'WATCH':PRIORITY_WATCH}, Error = window.Error, - jQuery = window['jQuery'] || window['$'], // weirdness to make IE happy - _ = window['_'], /** holds major version number for IE or NaN for real browsers */ msie = parseInt((/msie (\d+)/.exec(lowercase(navigator.userAgent)) || [])[1], 10), - jqLite = jQuery || jqLiteWrap, + jqLite, // delay binding since jQuery could be loaded after us. + jQuery, // delay binding slice = Array.prototype.slice, push = Array.prototype.push, error = window[$console] ? bind(window[$console], window[$console]['error'] || noop) : noop, /** @name angular */ - angular = window[$angular] || (window[$angular] = {}), + angular = window[$angular] || (window[$angular] = {}), /** @name angular.markup */ angularTextMarkup = extensionMap(angular, 'markup'), /** @name angular.attrMarkup */ @@ -1006,6 +1005,7 @@ function angularInit(config){ } function angularJsConfig(document, config) { + bindJQuery(); var scripts = document.getElementsByTagName("script"), match; config = extend({ @@ -1028,3 +1028,9 @@ function angularJsConfig(document, config) { } return config; } + +function bindJQuery(){ + // bind to jQuery if present; + jQuery = window.jQuery; + angular.element = jqLite = jQuery || jqLiteWrap; +} -- cgit v1.2.3