Permalink
Browse files

all tests green again

  • Loading branch information...
Tobias Bosch
Tobias Bosch committed May 10, 2012
1 parent 01957d0 commit 51bdf8d6f9ae860b70ac3b7cbae70c989252d17d
View
@@ -3,9 +3,12 @@ Changelog
1.0.7rc1
-------------
-- extracted the jquery mobile change detection into the jquery mobile autorefresh plugin.
-- refactored the internal structure into code that is needed for integration and code that contains
- utility functions.
+- Update to angular 1.0rc8
+- refactoring for performance improvements.
+- Removed `$navigate` filter. Use `$navigate` service instead. Reason: This puts too much logic in the html page and leads
+ to errors if `$q` is not used correctly.
+- Removed the `fadein` directive, as there are better ways to do this (see the corresponding jquery mobile plugin...)
+
1.0.7rc1
-------------
View
@@ -115,13 +115,6 @@ using the `ngm-event` directive with the corresponding event name.
Usage: E.g. `<a href="#" ngm-swipeleft="myFn()">`
-### Directive ngm-fadein
-For smooth fadings between `ngm-if` changes, there is also the directive `ngm-fadein`.
-This specifies that the display of the coresponding element
-should be shown via a transition lasting a defined amount of milliseconds (the value of the attribute).
-
-Usage: E.g. `<div ngm-fadein="700">asdf</div>`
-
### Attribute Widget @ngm-if
The attribute widget `@ngm-if` allows to add/remove an element to/from the dom, depending on an expression.
@@ -161,22 +154,6 @@ Default messages are:
- `$.mobile.loadingMessage`: for all other cases
-### Filter `navigate`: Navigation in Expressions
-Every expression can now use the `$navigate` as a filter to define the navigation outside of the controlers
-in the html pages. By this, the controllers stay independent of the navigation process and is reusable.
-
-Syntax: `test | $activate: 'outcome1:target' : 'outcome2:target' : ...`
-
-Example: `<button ngm-click="doSomething() | navigate : 'success:successPage' : 'failure:failurePage'">`
-
-This navigates to that target whose outcome equals
-to the test. The special outcomes `success` is applied for any value for `test` that is not `false` (e.g. also `undefined`),
-and the outcome `failure` is used for the value `false` of test.
-This also supports promises. In that case, the navivation is done with the first argument of
-the `done` / `fail` callback of the promise. Also, the `success` outcome is mapped to the `done` callback
-and the `failure` outcome to the `fail` callback.
-
-
### Filter `paged`: Paging for lists
Lists can be paged in the sense that more entries can be additionally loaded. By "loading" we mean the
display of a sublist of a list that is already fully loaded in JavaScript. This is useful, as the main performance
@@ -18,7 +18,7 @@
var p = $.mobile.activePage;
var activeScope = p && p.scope();
if (lastActiveScope && lastActiveScope !== activeScope) {
- lastActiveScope.$destroy();
+ lastActiveScope.$disconnect();
}
lastActiveScope = activeScope;
if (activeScope) {
@@ -80,7 +80,7 @@
// Detach the scope from the normal $digest cycle.
// Needed so that only $.mobile.activePage gets digested when rootScope.$digest
// is called.
- scope.$destroy();
+ scope.$disconnect();
}
}
}
@@ -3,23 +3,25 @@
var ng = angular.module('ng');
ng.config(['$provide', function($provide) {
$provide.decorator('$rootScope', ['$delegate', function($rootScope) {
- var _$destroy = $rootScope.$destroy;
- $rootScope.$destroy = function() {
- this.$$destroyed = true;
- var res = _$destroy.apply(this, arguments);
+ $rootScope.$disconnect = function() {
+ if (this.$root == this) return; // we can't disconnect the root node;
+ var parent = this.$parent;
+ this.$$disconnected = true;
+ // See Scope.$destroy
+ if (parent.$$childHead == this) parent.$$childHead = this.$$nextSibling;
+ if (parent.$$childTail == this) parent.$$childTail = this.$$prevSibling;
+ if (this.$$prevSibling) this.$$prevSibling.$$nextSibling = this.$$nextSibling;
+ if (this.$$nextSibling) this.$$nextSibling.$$prevSibling = this.$$prevSibling;
this.$$nextSibling = this.$$prevSibling = null;
};
$rootScope.$reconnect = function() {
+ if (this.$root == this) return; // we can't disconnect the root node;
var child = this;
- if (child===$rootScope) {
- // Nothing to do here.
- return;
- }
- if (!child.$$destroyed) {
+ if (!child.$$disconnected) {
return;
}
var parent = child.$parent;
- child.$$destroyed = false;
+ child.$$disconnected = false;
// See Scope.$new for this logic...
child.$$prevSibling = parent.$$childTail;
if (parent.$$childHead) {
@@ -34,18 +34,22 @@
<jsp:include page="lib/jquery.mobile.js"/>
<jsp:include page="lib/angular.js"/>
-<jsp:include page="autorefresh/main.jsp"/>
-
+<jsp:include page="integration/jqmDestroyFix.js"/>
<jsp:include page="integration/scopeReconnect.js"/>
-<jsp:include page="integration/angularInput.js"/>
-<jsp:include page="integration/angularRepeat.js"/>
-<jsp:include page="integration/angularNgModel.js"/>
+<jsp:include page="integration/scopeReentrance.js"/>
<jsp:include page="integration/pageCompile.js"/>
+<jsp:include page="integration/jqmAngularWidgets.js"/>
+<jsp:include page="integration/deactivateNgLocationChange.js"/>
+<jsp:include page="integration/angularNgRepeat.js"/>
+<jsp:include page="integration/angularNgOptions.js"/>
+<jsp:include page="integration/angularOption.js"/>
+<jsp:include page="integration/angularNgSwitch.js"/>
+<jsp:include page="integration/angularNgInclude.js"/>
+<jsp:include page="integration/angularInput.js"/>
-<jsp:include page="utils/event.js"/>
<jsp:include page="utils/if.js"/>
+<jsp:include page="utils/event.js"/>
<jsp:include page="utils/navigate.js"/>
<jsp:include page="utils/sharedController.js"/>
<jsp:include page="utils/waitDialog.js"/>
<jsp:include page="utils/paging.js"/>
-<jsp:include page="utils/fadein.js"/>
@@ -19,14 +19,8 @@
<jsp:include page="integration/angularInput.js"/>
<jsp:include page="utils/if.js"/>
-
-<%--
-
<jsp:include page="utils/event.js"/>
<jsp:include page="utils/navigate.js"/>
<jsp:include page="utils/sharedController.js"/>
<jsp:include page="utils/waitDialog.js"/>
<jsp:include page="utils/paging.js"/>
-<jsp:include page="utils/fadein.js"/>
-
---%>
@@ -1,16 +0,0 @@
-(function(angular) {
- /*
- * Directive that fades in an element when angular
- * uses it. Useful in templating when the underlying template changed.
- */
- angular.module(["ng"]).directive("ngmFadein", function() {
- return {
- compile: function(element) {
- element.css({opacity:0.1});
- return function(scope, element, attrs) {
- element.animate({opacity:1.0}, parseInt(attrs.ngmFadein));
- }
- }
- };
- });
-})(window.angular);
@@ -95,50 +95,6 @@
return undefined;
}
- mod.run(['$rootScope', '$navigate', function($rootScope, $navigate) {
- $rootScope.$navigate = function() {
- var args = Array.prototype.slice.call(arguments);
- args.unshift($navigate);
- return navigateExpression.apply(this, args);
- }
- }]);
-
- mod.filter('navigate', ['$navigate', function($navigateService) {
- return function(test) {
- // parse the arguments...
- var outcomes = {};
- var parts;
- for (var i = 1; i < arguments.length; i++) {
- parts = splitAtFirstColon(arguments[i]);
- outcomes[parts[0]] = parts[1];
- }
- if (test && test.then) {
- // test is a promise.
- test.then(function(test) {
- if (outcomes[test]) {
- $navigateService(outcomes[test]);
- } else if (outcomes.success) {
- $navigateService(outcomes.success);
- }
- }, function(test) {
- if (outcomes[test]) {
- $navigateService(outcomes[test]);
- } else if (outcomes.failure) {
- $navigateService(outcomes.failure);
- }
- });
- } else {
- if (outcomes[test]) {
- $navigateService(outcomes[test]);
- } else if (test !== false && outcomes.success) {
- $navigateService(outcomes.success);
- } else if (test === false && outcomes.failure) {
- $navigateService(outcomes.failure);
- }
- }
- };
- }]);
-
return navigate;
})(window.jQuery, window.angular);
@@ -9,13 +9,11 @@
<script src="ui/integration/compileIntegrationSpec.js"></script>
<script src="ui/integration/angularUrlIntegrationSpec.js"></script>
- <!--
<script src="ui/standaloneBuildTest.js"></script>
<script src="ui/integration/selectmenuSpec.js"></script>
<script src="ui/integration/regressionSpec.js"></script>
<script src="ui/utils/waitDialogServiceSpec.js"></script>
<script src="ui/utils/navigateSpec.js"></script>
- -->
</head>
<body>
<script>
@@ -34,17 +34,12 @@
<script src="unit/integration/regressionSpec.js" type="text/javascript"></script>
<script src="unit/integration/ngSwitchSpec.js" type="text/javascript"></script>
<script src="unit/integration/ngIncludeSpec.js" type="text/javascript"></script>
- <script src="unit/utils/ifSpec.js" type="text/javascript"></script>
- <!--
-
-
+ <script src="unit/utils/ifSpec.js" type="text/javascript"></script>
+ <script src="unit/utils/navigateSpec.js" type="text/javascript"></script>
<script src="unit/utils/eventSpec.js" type="text/javascript"></script>
<script src="unit/utils/sharedControllerSpec.js" type="text/javascript"></script>
- <script src="unit/utils/navigateSpec.js" type="text/javascript"></script>
<script src="unit/utils/arrayPagingSpec.js" type="text/javascript"></script>
- <script src="unit/utils/fadeinSpec.js" type="text/javascript"></script>
- -->
<script>
$(function(doc) {
@@ -32,52 +32,6 @@ describe('compileIntegration', function () {
expect(extPageScope).not.toBe(extPageScope.$root);
expect(extPageScope.$root).toBe(page1Scope.$root);
});
-
- });
-
- it("should not angular compile pages created manually calling the page plugin", function () {
- loadHtml('/jqmng/ui/test-fixture.html');
- runs(function () {
- var $ = testframe().$;
- var page3 = $('<div id="externalPage" data-role="page">{{1+2}}</div>');
- $("body").append(page3);
- page3.page();
- expect(page3.text()).toBe('{{1+2}}');
- expect(page3.scope()).toBe(page3.scope().$root);
- });
-
- });
-
- it('should use the $rootScope as parent of all page scopes', function () {
- loadHtml('/jqmng/ui/test-fixture.html');
- runs(function () {
- var win = testframe();
- var page1 = win.$("#start");
- page1.page();
- expect(page1.scope()).toBeTruthy();
- expect(page1.scope().$root).toBe(win.$(win.document.documentElement).scope());
- });
- });
-
- it("should work with degraded inputs", function () {
- loadHtml('/jqmng/ui/test-fixture.html', function (win) {
- var $ = win.$;
- $.mobile.page.prototype.options.degradeInputs.number = "text";
- var page1 = $("#start");
- page1.append('<input type="number" ng-model="myname" id="myname">');
- });
- runs(function () {
- var win = testframe();
- var $ = win.$;
- var page1 = $("#start");
- var input = page1.find("#myname");
- expect(input.length).toBe(1);
- expect(input.attr("type")).toBe("text");
- var scope = page1.scope();
- scope.myname = 1234;
- scope.$digest();
- expect(input.val()).toBe("1234");
- })
});
it("should evaluate the widget.prototype.options.initSelector and register corresponding angular directives", function() {
@@ -1,25 +1,23 @@
-jqmng.require([], function() {
- describe('standalone', function() {
- it('should use the globalScope as parent of all page scopes', function() {
- loadHtml('/jqmng/ui/test-fixture-standalone.html', function(frame) {
- var page = frame.$('#start');
- page.append('<div data-role="content">'+
- '<ul data-role="listview" ng-init="list=[1,2,3]" id="list">'+
- '<li ng-repeat="l in list">{{l}}</li>'+
- '</ul>'+
+describe('standalone', function () {
+ it('should work in standalone mode and call the mobileInit function', function () {
+ loadHtml('/jqmng/ui/test-fixture-standalone.html', function (frame) {
+ var page = frame.$('#start');
+ page.append('<div data-role="content">' +
+ '<ul data-role="listview" ng-init="list=[1,2,3]" id="list">' +
+ '<li ng-repeat="l in list">{{l}}</li>' +
+ '</ul>' +
'</div>');
- });
- runs(function() {
- var win = testframe();
- expect(win.mobileInitTest).toBe(true);
- var list = win.$("#list");
- var lis = list.children();
- expect(lis.length).toBe(3);
- for (var i=0; i<3; i++) {
- expect(lis.eq(i).hasClass("ui-li")).toBe(true);
- }
- });
});
-
+ runs(function () {
+ var win = testframe();
+ expect(win.mobileInitTest).toBe(true);
+ var list = win.$("#list");
+ var lis = list.children();
+ expect(lis.length).toBe(3);
+ for (var i = 0; i < 3; i++) {
+ expect(lis.eq(i).hasClass("ui-li")).toBe(true);
+ }
+ });
});
+
});
@@ -44,6 +44,17 @@ describe('compileIntegrationUnit', function () {
expect(btn1).not.toBe(btn2);
});
+ it("should not angular compile pages created manually calling the page plugin", function () {
+ var container = testutils.compile("<div></div>");
+ var page = $('<div id="externalPage" data-role="page">{{1+2}}</div>');
+ container.append(page);
+ page.page();
+ expect(page.text()).toBe('{{1+2}}');
+ expect(page.scope()).toBe(container.scope());
+ page.remove();
+
+ });
+
describe("partials loaded by angular", function() {
var containerCompile;
Oops, something went wrong.

0 comments on commit 51bdf8d

Please sign in to comment.