Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6231831

Browse files
committed
minW yarn test fixes
* fixed gridstack#2964 yarn test breaking (good thing for unit tests!)
1 parent 00e40f4 commit 6231831

File tree

2 files changed

+3
-13
lines changed

2 files changed

+3
-13
lines changed

spec/gridstack-spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,9 +1252,9 @@ describe('gridstack >', function() {
12521252
grid.update(el, {maxW: 2});
12531253
expect(parseInt(el.getAttribute('gs-x'), 10)).toBe(4);
12541254
expect(parseInt(el.getAttribute('gs-y'), 10)).toBe(0);
1255+
expect(parseInt(el.getAttribute('gs-w'), 10)).toBe(2);
12551256
expect(parseInt(el.getAttribute('gs-h'), 10)).toBe(4);
12561257
expect(el.gridstackNode.maxW).toBe(2);
1257-
expect(parseInt(el.getAttribute('gs-w'), 10)).toBe(2);
12581258
});
12591259
it('should change all max and move, no inf loop! >', function() {
12601260
grid = GridStack.init({float: true});

src/gridstack.ts

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ export class GridStack {
510510

511511
return el;
512512
}
513-
513+
514514
/**
515515
* Convert an existing gridItem element into a sub-grid with the given (optional) options, else inherit them
516516
* from the parent's subGrid options.
@@ -1312,20 +1312,10 @@ export class GridStack {
13121312
*/
13131313
public update(els: GridStackElement, opt: GridStackWidget): GridStack {
13141314

1315-
// support legacy call for now ?
1316-
if (arguments.length > 2) {
1317-
console.warn('gridstack.ts: `update(el, x, y, w, h)` is deprecated. Use `update(el, {x, w, content, ...})`. It will be removed soon');
1318-
// eslint-disable-next-line prefer-rest-params
1319-
const a = arguments;
1320-
let i = 1;
1321-
opt = { x: a[i++], y: a[i++], w: a[i++], h: a[i++] };
1322-
return this.update(els, opt);
1323-
}
1324-
13251315
GridStack.getElements(els).forEach(el => {
13261316
const n = el?.gridstackNode;
13271317
if (!n) return;
1328-
const w = Utils.cloneDeep(opt); // make a copy we can modify in case they re-use it or multiple items
1318+
const w = {...Utils.copyPos({}, n), ...Utils.cloneDeep(opt)}; // make a copy we can modify in case they re-use it or multiple items
13291319
this.engine.nodeBoundFix(w);
13301320
delete w.autoPosition;
13311321

0 commit comments

Comments
 (0)