Skip to content

Commit b47d607

Browse files
committed
Merge branch 'release/0.11.0'
2 parents 24408e8 + de3f970 commit b47d607

File tree

7 files changed

+38
-9
lines changed

7 files changed

+38
-9
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ language: node_js
33
sudo: false
44

55
node_js:
6-
- "0.10"
6+
- "0.12"
77

88
before_script:
99
- "npm update -g npm"

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "ngHandsontable",
33
"dependencies": {
44
"angular": "~1.4",
5-
"handsontable": "~0.23.0"
5+
"handsontable": "~0.24.0"
66
},
77
"homepage": "https://github.com/handsontable/ngHandsontable",
88
"authors": [

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"url": "https://github.com/handsontable/ngHandsontable/issues"
1111
},
1212
"author": "Marcin Warpechowski <[email protected]>",
13-
"version": "0.10.0",
13+
"version": "0.11.0",
1414
"devDependencies": {
1515
"angular": "^1.5.0",
1616
"angular-mocks": "^1.5.0",

src/directives/hotTable.js

+13-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@
117117
} else {
118118
scope.hotInstance.loadData(newValue);
119119
scope.htSettings.data = newValue;
120-
121120
}
122121
} else if (newValue !== oldValue) {
123122
scope.htSettings[key] = newValue;
@@ -126,6 +125,19 @@
126125
}, ['datarows', 'columns', 'rowHeights', 'colWidths', 'rowHeaders', 'colHeaders'].indexOf(key) >= 0);
127126
});
128127

128+
/**
129+
* Check for reference equality changes for datarows
130+
* TODO: must the remaining bindingsKeys need to be added also if their reference changes
131+
*/
132+
scope.$watch('datarows', function(newValue) {
133+
if (newValue === void 0) {
134+
return;
135+
}
136+
if (scope.hotInstance.getSettings().data !== newValue) {
137+
scope.hotInstance.loadData(newValue);
138+
}
139+
});
140+
129141
/**
130142
* Check if data length has been changed
131143
*/

src/services/settingFactory.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
container.className = this.containerClassName;
3434

35-
if (!container.id && htSettings.hotId) {
35+
if (htSettings.hotId) {
3636
container.id = htSettings.hotId;
3737
}
3838
element[0].appendChild(container);

test/directives/hotTable/watchingOptions.spec.js

+19
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,25 @@ describe('hotTable - Watching options', function() {
2424
expect(scope.hotInstance.getData()).toEqual([[null]]);
2525
});
2626

27+
it('should ensure a new copy of `datarows` is made when the reference is changed but it has the same value', function() {
28+
rootScope.value = [[1,2,3,4]];
29+
var scope = angular.element(compile('<hot-table datarows="value"></hot-table>')(rootScope)).isolateScope();
30+
31+
scope.$digest();
32+
33+
expect(scope.hotInstance.getSettings().data).toBe(rootScope.value);
34+
35+
rootScope.value = [[1, 2, 3, 4]];
36+
rootScope.$digest();
37+
38+
expect(scope.hotInstance.getSettings().data).toBe(rootScope.value);
39+
40+
rootScope.value.push([[5, 6, 7, 8]]);
41+
scope.$digest();
42+
43+
expect(scope.hotInstance.getSettings().data).toBe(rootScope.value);
44+
});
45+
2746
it('should create table with `dataSchema` attribute', function() {
2847
rootScope.value = {id: null};
2948
var scope = angular.element(compile('<hot-table dataschema="value"></hot-table>')(rootScope)).isolateScope();

test/services/settingFactory.spec.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('settingFactory', function() {
2828
window.Handsontable = HandsontableOrg;
2929
}));
3030

31-
it('should create new div element with "id" defined from hot-id attribute', inject(function(settingFactory) {
31+
it('should set "id" attribute of wrapper element when "hot-id" attribute is defined', inject(function(settingFactory) {
3232
var element = [{appendChild: jasmine.createSpy('appendChild')}];
3333
var hotSettings = {hotId: 'my-table', colHeaders: [1, 2], width: 200, columns: [{width: 100}]};
3434
var hotInstance = {};
@@ -41,9 +41,7 @@ describe('settingFactory', function() {
4141

4242
settingFactory.initializeHandsontable(element, hotSettings);
4343

44-
expect(element[0].appendChild).toHaveBeenCalled();
45-
expect(element[0].appendChild.calls.argsFor(0)[0].nodeName).toBe('DIV');
46-
expect(hotInstance.element.id).toBe('my-table');
44+
expect(element[0].appendChild.calls.argsFor(0)[0].id).toBe('my-table');
4745

4846
window.Handsontable = HandsontableOrg;
4947
}));

0 commit comments

Comments
 (0)