mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
allow jquery to be declared after angular in the script loading order
This commit is contained in:
parent
037f30a0c9
commit
a004d487c4
6 changed files with 21 additions and 7 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,3 +46,8 @@ extend(angular, {
|
|||
'isArray': isArray
|
||||
});
|
||||
|
||||
//try to bind to jquery now so that one can write angular.element().read()
|
||||
//but we will rebind on bootstrap again.
|
||||
bindJQuery();
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
jqLite(document).ready(function(){
|
||||
jqLiteWrap(document).ready(function(){
|
||||
angularInit(angularJsConfig(document));
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -97,7 +97,8 @@ JQLite.prototype = {
|
|||
}
|
||||
|
||||
this.bind('DOMContentLoaded', trigger); // works for modern browsers and IE9
|
||||
jqLite(window).bind('load', trigger); // fallback to window.onload for others
|
||||
// we can not use jqLite since we are not done loading and jQuery could be loaded later.
|
||||
new JQLite(window).bind('load', trigger); // fallback to window.onload for others
|
||||
},
|
||||
|
||||
bind: function(type, fn){
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
var $scenario = new angular.scenario.Runner(window);
|
||||
|
||||
jqLite(document).ready(function() {
|
||||
jqLiteWrap(document).ready(function() {
|
||||
angularScenarioInit($scenario, angularJsConfig(document));
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,8 @@ if (window.jstestdriver) {
|
|||
beforeEach(function(){
|
||||
// This is to reset parsers global cache of expressions.
|
||||
compileCache = {};
|
||||
// reset to jQuery or default to us.
|
||||
bindJQuery();
|
||||
this.addMatchers({
|
||||
toBeInvalid: function(){
|
||||
var element = jqLite(this.actual);
|
||||
|
|
|
|||
Loading…
Reference in a new issue