mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 23:40: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_LAST = 99999,
|
||||||
PRIORITY = {'FIRST': PRIORITY_FIRST, 'LAST': PRIORITY_LAST, 'WATCH':PRIORITY_WATCH},
|
PRIORITY = {'FIRST': PRIORITY_FIRST, 'LAST': PRIORITY_LAST, 'WATCH':PRIORITY_WATCH},
|
||||||
Error = window.Error,
|
Error = window.Error,
|
||||||
jQuery = window['jQuery'] || window['$'], // weirdness to make IE happy
|
|
||||||
_ = window['_'],
|
|
||||||
/** holds major version number for IE or NaN for real browsers */
|
/** holds major version number for IE or NaN for real browsers */
|
||||||
msie = parseInt((/msie (\d+)/.exec(lowercase(navigator.userAgent)) || [])[1], 10),
|
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,
|
slice = Array.prototype.slice,
|
||||||
push = Array.prototype.push,
|
push = Array.prototype.push,
|
||||||
error = window[$console] ? bind(window[$console], window[$console]['error'] || noop) : noop,
|
error = window[$console] ? bind(window[$console], window[$console]['error'] || noop) : noop,
|
||||||
|
|
||||||
/** @name angular */
|
/** @name angular */
|
||||||
angular = window[$angular] || (window[$angular] = {}),
|
angular = window[$angular] || (window[$angular] = {}),
|
||||||
/** @name angular.markup */
|
/** @name angular.markup */
|
||||||
angularTextMarkup = extensionMap(angular, 'markup'),
|
angularTextMarkup = extensionMap(angular, 'markup'),
|
||||||
/** @name angular.attrMarkup */
|
/** @name angular.attrMarkup */
|
||||||
|
|
@ -1006,6 +1005,7 @@ function angularInit(config){
|
||||||
}
|
}
|
||||||
|
|
||||||
function angularJsConfig(document, config) {
|
function angularJsConfig(document, config) {
|
||||||
|
bindJQuery();
|
||||||
var scripts = document.getElementsByTagName("script"),
|
var scripts = document.getElementsByTagName("script"),
|
||||||
match;
|
match;
|
||||||
config = extend({
|
config = extend({
|
||||||
|
|
@ -1028,3 +1028,9 @@ function angularJsConfig(document, config) {
|
||||||
}
|
}
|
||||||
return 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
|
'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));
|
angularInit(angularJsConfig(document));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,8 @@ JQLite.prototype = {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.bind('DOMContentLoaded', trigger); // works for modern browsers and IE9
|
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){
|
bind: function(type, fn){
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
var $scenario = new angular.scenario.Runner(window);
|
var $scenario = new angular.scenario.Runner(window);
|
||||||
|
|
||||||
jqLite(document).ready(function() {
|
jqLiteWrap(document).ready(function() {
|
||||||
angularScenarioInit($scenario, angularJsConfig(document));
|
angularScenarioInit($scenario, angularJsConfig(document));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,8 @@ if (window.jstestdriver) {
|
||||||
beforeEach(function(){
|
beforeEach(function(){
|
||||||
// This is to reset parsers global cache of expressions.
|
// This is to reset parsers global cache of expressions.
|
||||||
compileCache = {};
|
compileCache = {};
|
||||||
|
// reset to jQuery or default to us.
|
||||||
|
bindJQuery();
|
||||||
this.addMatchers({
|
this.addMatchers({
|
||||||
toBeInvalid: function(){
|
toBeInvalid: function(){
|
||||||
var element = jqLite(this.actual);
|
var element = jqLite(this.actual);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue