Skip to content

Commit 6979050

Browse files
Portugal, Marcelomportuga
authored andcommitted
Revert "fix(5007): Reduced the amount of digest cycles initiated by the grid."
This reverts commit d0bc03d.
1 parent f86de83 commit 6979050

File tree

2 files changed

+25
-73
lines changed

2 files changed

+25
-73
lines changed

src/js/core/services/ui-grid-util.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,10 @@ module.service('gridUtil', ['$log', '$window', '$document', '$http', '$templateC
619619
},
620620

621621
isNullOrUndefined: function(obj) {
622-
return (obj === undefined || obj === null);
622+
if (obj === undefined || obj === null) {
623+
return true;
624+
}
625+
return false;
623626
},
624627

625628
endsWith: function(str, suffix) {
@@ -828,7 +831,7 @@ module.service('gridUtil', ['$log', '$window', '$document', '$http', '$templateC
828831
} else {
829832
s.logWarn('[focus.byId] Element id ' + elementID + ' was not found.');
830833
}
831-
}, 0, false);
834+
});
832835
this.queue.push(promise);
833836
return promise;
834837
},
@@ -853,7 +856,7 @@ module.service('gridUtil', ['$log', '$window', '$document', '$http', '$templateC
853856
if (element){
854857
element[0].focus();
855858
}
856-
}, 0, false);
859+
});
857860
this.queue.push(promise);
858861
return promise;
859862
},
@@ -883,8 +886,8 @@ module.service('gridUtil', ['$log', '$window', '$document', '$http', '$templateC
883886
};
884887
this._purgeQueue();
885888
if (aSync){ //Do this asynchronysly
886-
var promise = $timeout(focusBySelector, 0, false);
887-
this.queue.push(promise);
889+
var promise = $timeout(focusBySelector);
890+
this.queue.push($timeout(focusBySelector));
888891
return promise;
889892
} else {
890893
return focusBySelector();

test/unit/core/services/ui-grid-util.spec.js

Lines changed: 17 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,22 @@ describe('ui.grid.utilService', function() {
66
$q,
77
$interpolateProvider;
88

9-
beforeEach(function() {
10-
module('ui.grid', function (_$interpolateProvider_) {
11-
$interpolateProvider = _$interpolateProvider_;
12-
});
13-
14-
inject(function(_$rootScope_, _$q_, _gridUtil_, _$window_, _Grid_) {
15-
gridUtil = _gridUtil_;
16-
$window = _$window_;
17-
Grid = _Grid_;
18-
$rootScope = _$rootScope_;
19-
$q = _$q_;
20-
});
21-
});
9+
beforeEach(module('ui.grid', function (_$interpolateProvider_) {
10+
$interpolateProvider = _$interpolateProvider_;
11+
}));
12+
13+
beforeEach(inject(function(_$rootScope_, _$q_, _gridUtil_, _$window_, _Grid_) {
14+
gridUtil = _gridUtil_;
15+
$window = _$window_;
16+
Grid = _Grid_;
17+
$rootScope = _$rootScope_;
18+
$q = _$q_;
19+
}));
2220

2321
describe('newId()', function() {
2422
it('creates a unique id each time it is called', function() {
25-
var id1 = gridUtil.newId(),
26-
id2 = gridUtil.newId();
23+
var id1 = gridUtil.newId();
24+
var id2 = gridUtil.newId();
2725

2826
expect(id1).not.toEqual(id2);
2927
});
@@ -534,14 +532,12 @@ describe('ui.grid.utilService', function() {
534532
/* Create Button1 */
535533
button1 = document.createElement('button');
536534
aButton1 = angular.element(button1);
537-
aButton1.attr('id', 'aButton1');
538535
aButton1.attr('type', 'button');
539536
// The class is not set here because it is set inside of tests if needed
540537

541538
/* Create Button2 */
542539
button2 = document.createElement('button');
543540
aButton2 = angular.element(button1);
544-
aButton2.attr('id', 'aButton2');
545541
aButton2.attr('type', 'button');
546542
aButton2.addClass(button2class);
547543

@@ -561,61 +557,14 @@ describe('ui.grid.utilService', function() {
561557
expect(element.innerHTML).toEqual(document.activeElement.innerHTML);
562558
}
563559

564-
describe('byId', function() {
565-
describe('when the grid is not defined', function() {
566-
it('should focus on the element with the id passed', function(){
567-
gridUtil.focus.byId('aButton2');
568-
$timeout.flush();
569-
570-
expectFocused(button2);
571-
});
572-
});
573-
describe('when the grid is defined', function() {
574-
it('should focus on the element with the grid id and the id passed', function(){
575-
var gridId = 'gridId';
576-
577-
aButton2.attr('id', 'gridId-aButton2');
578-
gridUtil.focus.byId('aButton2', {id: gridId});
579-
$timeout.flush();
580-
581-
expectFocused(button2);
582-
});
583-
});
584-
describe('when the id passed in is not in the dom', function() {
585-
it('should keep focus on the body', function() {
586-
gridUtil.focus.byId('notAnElement');
587-
$timeout.flush();
588-
589-
expectFocused(document.body);
590-
});
591-
});
592-
});
593560
describe('byElement', function(){
594-
describe('when argument passed is an element', function() {
595-
it('should focus on the element passed', function(){
596-
gridUtil.focus.byElement(button1);
597-
$timeout.flush();
598-
expectFocused(button1);
599-
});
600-
});
601-
describe('when argument passed is not an element', function() {
602-
it('should keep focus on the body', function(){
603-
gridUtil.focus.byElement('');
604-
expectFocused(document.body);
605-
});
561+
it('should focus on the element passed', function(){
562+
gridUtil.focus.byElement(button1);
563+
$timeout.flush();
564+
expectFocused(button1);
606565
});
607566
});
608567
describe('bySelector', function(){
609-
describe('when argument passed is not an element', function() {
610-
it('should throw an error', function(done){
611-
try {
612-
gridUtil.focus.bySelector('');
613-
} catch (error) {
614-
expect(error.message).toEqual('The parent element is not an element.');
615-
done();
616-
}
617-
});
618-
});
619568
it('should focus on an elment using a selector', function(){
620569
gridUtil.focus.bySelector(elm, '.' + button2class);
621570
$timeout.flush();

0 commit comments

Comments
 (0)