Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 5b47bc4

Browse files
committed
check jquery version inside directives, expose it on scope
1 parent 218e011 commit 5b47bc4

File tree

6 files changed

+53
-15
lines changed

6 files changed

+53
-15
lines changed

test/e2e/fixtures/ngJq/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<!DOCTYPE html>
22
<html ng-app="test" ng-jq>
33

4+
<jquery-version>{{jqueryVersion}}</jquery-version>
5+
46
<script src="../../../../bower_components/jquery/dist/jquery.js"></script>
57
<script src="angular.js"></script>
6-
<script>
7-
angular.module('test', []);
8-
</script>
8+
<script type="text/javascript" src="script.js"></script>
99
</html>

test/e2e/fixtures/ngJq/script.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict';
2+
3+
angular.module('test', [])
4+
.directive('jqueryVersion', function() {
5+
return {
6+
link: function(scope) {
7+
if (window.angular.element !== window.jQuery) {
8+
scope.jqueryVersion = 'jqLite';
9+
}
10+
}
11+
};
12+
});
Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
<!DOCTYPE html>
2-
<html ng-app="test" ng-jq="jQuery_2_0_0">
2+
<html ng-app="test" ng-jq="jQuery_2_1_0">
33

4-
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
5-
<script>
6-
var jQuery_2_0_0 = $.noConflict(true);
7-
</script>
8-
<script src="../../../../bower_components/jquery/dist/jquery.js"></script>
9-
<script src="angular.js"></script>
10-
<script>
11-
angular.module('test', []);
12-
</script>
4+
<jquery-version>{{jqueryVersion}}</jquery-version>
5+
6+
<script src="../../../../bower_components/jquery/dist/jquery.js"></script>
7+
<script src="jquery2.1.0.min.js"></script>
8+
<!-- <script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> -->
9+
<script>
10+
var jQuery_2_1_0 = jQuery.noConflict();
11+
</script>
12+
<script src="angular.js"></script>
13+
<script type="text/javascript" src="script.js"></script>
1314
</html>

test/e2e/fixtures/ngJqJquery/jquery2.1.0.min.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
'use strict';
2+
3+
angular.module('test', [])
4+
.directive('jqueryVersion', function() {
5+
return {
6+
link: function(scope) {
7+
8+
// scope.jqueryVersion = angular.isDefined(window.jQuery_2_1_0);
9+
// scope.jqueryVersion = angular.isDefined(window.jQuery_2_1_0().jquery);
10+
// scope.jqueryVersion = window.jQuery_2_1_0().jquery;
11+
12+
scope.jqueryVersion = window.angular.element().jquery;
13+
// scope.jqueryVersion = window.jQuery_2_1_0().jquery;
14+
// scope.jqueryVersion = window.$().jquery;
15+
16+
if (window.angular.element === window.jQuery_2_1_0) {
17+
// scope.jqueryVersion = 'jQuery_2_0_0';
18+
}
19+
}
20+
};
21+
});

test/e2e/tests/ngJqSpec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ describe('Customizing the jqlite / jquery version', function() {
22

33
it('should be able to force jqlite', function() {
44
loadFixture("ngJq").andWaitForAngular();
5-
expect(browser.executeScript('return window.angular.element !== window.jQuery')).toBe(true);
5+
expect(element(by.binding('jqueryVersion')).getText()).toBe('jqLite');
66
});
77

88
it('should be able to use a specific version jQuery', function() {
99
loadFixture("ngJqJquery").andWaitForAngular();
10-
expect(browser.executeScript('return window.angular.element !== window.jQuery_2_0_0')).toBe(true);
10+
expect(element(by.binding('jqueryVersion')).getText()).toBe('2.1.0');
1111
});
1212
});

0 commit comments

Comments
 (0)