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

Skip to content

minW yarn test fixes #2971

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion spec/gridstack-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1252,9 +1252,9 @@ describe('gridstack >', function() {
grid.update(el, {maxW: 2});
expect(parseInt(el.getAttribute('gs-x'), 10)).toBe(4);
expect(parseInt(el.getAttribute('gs-y'), 10)).toBe(0);
expect(parseInt(el.getAttribute('gs-w'), 10)).toBe(2);
expect(parseInt(el.getAttribute('gs-h'), 10)).toBe(4);
expect(el.gridstackNode.maxW).toBe(2);
expect(parseInt(el.getAttribute('gs-w'), 10)).toBe(2);
});
it('should change all max and move, no inf loop! >', function() {
grid = GridStack.init({float: true});
Expand Down
14 changes: 2 additions & 12 deletions src/gridstack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ export class GridStack {

return el;
}

/**
* Convert an existing gridItem element into a sub-grid with the given (optional) options, else inherit them
* from the parent's subGrid options.
Expand Down Expand Up @@ -1312,20 +1312,10 @@ export class GridStack {
*/
public update(els: GridStackElement, opt: GridStackWidget): GridStack {

// support legacy call for now ?
if (arguments.length > 2) {
console.warn('gridstack.ts: `update(el, x, y, w, h)` is deprecated. Use `update(el, {x, w, content, ...})`. It will be removed soon');
// eslint-disable-next-line prefer-rest-params
const a = arguments;
let i = 1;
opt = { x: a[i++], y: a[i++], w: a[i++], h: a[i++] };
return this.update(els, opt);
}

GridStack.getElements(els).forEach(el => {
const n = el?.gridstackNode;
if (!n) return;
const w = Utils.cloneDeep(opt); // make a copy we can modify in case they re-use it or multiple items
const w = {...Utils.copyPos({}, n), ...Utils.cloneDeep(opt)}; // make a copy we can modify in case they re-use it or multiple items
this.engine.nodeBoundFix(w);
delete w.autoPosition;

Expand Down