Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ module.exports = function(grunt) {
test: {
jqlite: 'karma-jqlite.conf.js',
jquery: 'karma-jquery.conf.js',
zepto: 'karma-zepto.conf.js',
docs: 'karma-docs.conf.js',
modules: 'karma-modules.conf.js',
//NOTE run grunt test:e2e instead and it will start a webserver for you
Expand Down Expand Up @@ -237,7 +238,7 @@ module.exports = function(grunt) {


//alias tasks
grunt.registerTask('test:unit', ['test:jqlite', 'test:jquery', 'test:modules']);
grunt.registerTask('test:unit', ['test:jqlite', 'test:jquery', 'test:zepto', 'test:modules']);
grunt.registerTask('test:docgen', ['jasmine-node']);
grunt.registerTask('minify', ['shell:bower','clean', 'build', 'minall']);
grunt.registerTask('test:e2e', ['connect:testserver', 'test:end2end']);
Expand Down
30 changes: 29 additions & 1 deletion angularFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,10 @@ angularFiles = {
],

'karma': [
'components/zepto/zepto.js',
'components/jquery/jquery.js',
'test/jquery_remove.js',
'test/zepto_remove.js',
'@angularSrc',
'src/publishExternalApis.js',
'@angularSrcModules',
Expand All @@ -128,6 +130,7 @@ angularFiles = {
],

'karmaExclude': [
'test/zepto_alias.js',
'test/jquery_alias.js',
'src/angular-bootstrap.js',
'src/ngScenario/angular-bootstrap.js'
Expand All @@ -154,7 +157,9 @@ angularFiles = {

'karmaJquery': [
'components/jquery/jquery.js',
'components/zepto/zepto.js',
'test/jquery_alias.js',
'test/zepto_remove.js',
'@angularSrc',
'src/publishExternalApis.js',
'@angularSrcModules',
Expand All @@ -168,7 +173,30 @@ angularFiles = {
'karmaJqueryExclude': [
'src/angular-bootstrap.js',
'src/ngScenario/angular-bootstrap.js',
'test/jquery_remove.js'
'test/jquery_remove.js',
'test/zepto_alias.js'
],

'karmaZepto': [
'components/jquery/jquery.js',
'components/zepto/zepto.js',
'test/zepto_alias.js',
'test/jquery_remove.js',
'@angularSrc',
'src/publishExternalApis.js',
'@angularSrcModules',
'@angularScenario',
'@angularTest',
'example/personalLog/*.js',

'example/personalLog/test/*.js'
],

'karmaZeptoExclude': [
'src/angular-bootstrap.js',
'src/ngScenario/angular-bootstrap.js',
'test/zepto_remove.js',
'test/jquery_alias.js'
]
};

Expand Down
1 change: 1 addition & 0 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "AngularJS",
"devDependencies": {
"jquery": "git://github.com/components/jquery.git#v1.8.3",
"zepto": "git://github.com/components/zepto#1.0.0",
"lunr.js": "0.4.0",
"google-code-prettify": "1.0.0",
"components-font-awesome": "3.1.0",
Expand Down
18 changes: 18 additions & 0 deletions karma-zepto.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
var angularFiles = require('./angularFiles');
var sharedConfig = require('./karma-shared.conf');

module.exports = function(config) {
sharedConfig(config);

config.set({
files: angularFiles.mergeFilesFor('karmaZepto'),
exclude: angularFiles.mergeFilesFor('karmaZeptoExclude'),

junitReporter: {
outputFile: 'test_out/zepto.xml',
suite: 'Zepto'
}
});

config.sauceLabs.testName = 'AngularJS: Zepto';
};
15 changes: 9 additions & 6 deletions src/Angular.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ if ('i' !== 'I'.toLowerCase()) {

var /** holds major version number for IE or NaN for real browsers */
msie = int((/msie (\d+)/.exec(lowercase(navigator.userAgent)) || [])[1]),
jqLite, // delay binding since jQuery could be loaded after us.
jqLite, // delay binding since jQuery or Zepto could be loaded after us.
jQuery, // delay binding
Zepto, // delay binding
slice = [].slice,
push = [].push,
toString = Object.prototype.toString,
Expand Down Expand Up @@ -1089,12 +1090,14 @@ function snake_case(name, separator){
}

function bindJQuery() {
// bind to jQuery if present;
// bind to jQuery or Zepto if present;
jQuery = window.jQuery;
// reset to jQuery or default to us.
if (jQuery) {
jqLite = jQuery;
extend(jQuery.fn, {
Zepto = window.Zepto;
// reset to jQuery or Zepto or default to us.
if (jQuery || Zepto || false) {
var binder = jQuery || Zepto;
jqLite = binder;
extend(binder.fn, {
scope: JQLitePrototype.scope,
controller: JQLitePrototype.controller,
injector: JQLitePrototype.injector,
Expand Down
7 changes: 4 additions & 3 deletions src/jqLite.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,11 @@ function camelCase(name) {
/////////////////////////////////////////////

function JQLitePatchJQueryRemove(name, dispatchThis, filterElems, getterIfNoArguments) {
var originalJqFn = jQuery.fn[name];
var binder = jQuery || Zepto,
originalJqFn = binder.fn[name];
originalJqFn = originalJqFn.$original || originalJqFn;
removePatch.$original = originalJqFn;
jQuery.fn[name] = removePatch;
binder.fn[name] = removePatch;

function removePatch(param) {
var list = filterElems && param ? [this.filter(param)] : [this],
Expand All @@ -147,7 +148,7 @@ function JQLitePatchJQueryRemove(name, dispatchThis, filterElems, getterIfNoArgu
for(childIndex = 0, childLength = (children = element.children()).length;
childIndex < childLength;
childIndex++) {
list.push(jQuery(children[childIndex]));
list.push(binder(children[childIndex]));
}
}
}
Expand Down
33 changes: 17 additions & 16 deletions src/ngScenario/Scenario.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,23 +233,24 @@ function callerFile(offset) {
*
* To work around this we instead use our own handler that fires a real event.
*/
(function(fn){
var parentTrigger = fn.trigger;
fn.trigger = function(type) {
if (/(click|change|keydown|blur|input|mousedown|mouseup)/.test(type)) {
var processDefaults = [];
this.each(function(index, node) {
processDefaults.push(browserTrigger(node, type));
});

// this is not compatible with jQuery - we return an array of returned values,
// so that scenario runner know whether JS code has preventDefault() of the event or not...
return processDefaults;
}
return parentTrigger.apply(this, arguments);
};
})(_jQuery.fn);
if (angular.isDefined(_jQuery)) {
(function(fn){
var parentTrigger = fn.trigger;
fn.trigger = function(type) {
if (/(click|change|keydown|blur|input|mousedown|mouseup)/.test(type)) {
var processDefaults = [];
this.each(function(index, node) {
processDefaults.push(browserTrigger(node, type));
});

// this is not compatible with jQuery - we return an array of returned values,
// so that scenario runner know whether JS code has preventDefault() of the event or not...
return processDefaults;
}
return parentTrigger.apply(this, arguments);
};
})(_jQuery.fn);
}
/**
* Finds all bindings with the substring match of name and returns an
* array of their values.
Expand Down
4 changes: 2 additions & 2 deletions test/jqLiteSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ describe('jqLite', function() {
});


it('should be jqLite when jqLiteMode is on, otherwise jQuery', function() {
expect(jqLite).toBe(_jqLiteMode ? JQLite : _jQuery);
it('should be jqLite when jqLiteMode is on, otherwise jQuery or Zepto', function() {
expect(jqLite).toBe(_jqLiteMode ? JQLite : (angular.isDefined(_jQuery)) ? _jQuery : _Zepto);
});


Expand Down
4 changes: 3 additions & 1 deletion test/jquery_remove.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
'use strict';

var _jQuery = jQuery.noConflict(true),
_jqLiteMode = true;
_jqLiteMode;

_jqLiteMode === false ? _jqLiteMode = false : _jqLiteMode = true;
4 changes: 4 additions & 0 deletions test/testabilityPatch.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ beforeEach(function() {
jQuery = _jQuery;
}

if (!_jqLiteMode && _Zepto !== Zepto) {
Zepto = _Zepto;
}

// This resets global id counter;
uid = ['0', '0', '0'];

Expand Down
4 changes: 4 additions & 0 deletions test/zepto_alias.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
'use strict';

var _Zepto = Zepto,
_jqLiteMode = false;
8 changes: 8 additions & 0 deletions test/zepto_remove.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

var _Zepto = Zepto,
_jqLiteMode;

Zepto = false;

_jqLiteMode === false ? _jqLiteMode = false : _jqLiteMode = true;