Skip to content

Commit

Permalink
Merge branch 'release/0.11.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
budnix committed May 20, 2016
2 parents 24408e8 + de3f970 commit b47d607
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ language: node_js
sudo: false

node_js:
- "0.10"
- "0.12"

before_script:
- "npm update -g npm"
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "ngHandsontable",
"dependencies": {
"angular": "~1.4",
"handsontable": "~0.23.0"
"handsontable": "~0.24.0"
},
"homepage": "https://github.com/handsontable/ngHandsontable",
"authors": [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"url": "https://github.com/handsontable/ngHandsontable/issues"
},
"author": "Marcin Warpechowski <hello@handsontable.com>",
"version": "0.10.0",
"version": "0.11.0",
"devDependencies": {
"angular": "^1.5.0",
"angular-mocks": "^1.5.0",
Expand Down
14 changes: 13 additions & 1 deletion src/directives/hotTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@
} else {
scope.hotInstance.loadData(newValue);
scope.htSettings.data = newValue;

}
} else if (newValue !== oldValue) {
scope.htSettings[key] = newValue;
Expand All @@ -126,6 +125,19 @@
}, ['datarows', 'columns', 'rowHeights', 'colWidths', 'rowHeaders', 'colHeaders'].indexOf(key) >= 0);
});

/**
* Check for reference equality changes for datarows
* TODO: must the remaining bindingsKeys need to be added also if their reference changes
*/
scope.$watch('datarows', function(newValue) {
if (newValue === void 0) {
return;
}
if (scope.hotInstance.getSettings().data !== newValue) {
scope.hotInstance.loadData(newValue);
}
});

/**
* Check if data length has been changed
*/
Expand Down
2 changes: 1 addition & 1 deletion src/services/settingFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

container.className = this.containerClassName;

if (!container.id && htSettings.hotId) {
if (htSettings.hotId) {
container.id = htSettings.hotId;
}
element[0].appendChild(container);
Expand Down
19 changes: 19 additions & 0 deletions test/directives/hotTable/watchingOptions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,25 @@ describe('hotTable - Watching options', function() {
expect(scope.hotInstance.getData()).toEqual([[null]]);
});

it('should ensure a new copy of `datarows` is made when the reference is changed but it has the same value', function() {
rootScope.value = [[1,2,3,4]];
var scope = angular.element(compile('<hot-table datarows="value"></hot-table>')(rootScope)).isolateScope();

scope.$digest();

expect(scope.hotInstance.getSettings().data).toBe(rootScope.value);

rootScope.value = [[1, 2, 3, 4]];
rootScope.$digest();

expect(scope.hotInstance.getSettings().data).toBe(rootScope.value);

rootScope.value.push([[5, 6, 7, 8]]);
scope.$digest();

expect(scope.hotInstance.getSettings().data).toBe(rootScope.value);
});

it('should create table with `dataSchema` attribute', function() {
rootScope.value = {id: null};
var scope = angular.element(compile('<hot-table dataschema="value"></hot-table>')(rootScope)).isolateScope();
Expand Down
6 changes: 2 additions & 4 deletions test/services/settingFactory.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('settingFactory', function() {
window.Handsontable = HandsontableOrg;
}));

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

settingFactory.initializeHandsontable(element, hotSettings);

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

window.Handsontable = HandsontableOrg;
}));
Expand Down

0 comments on commit b47d607

Please sign in to comment.