Skip to content
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ $(function () {

// you can now call on any grid this...
$('.grid-stack').data('gridstack').printCount();
});
});
```

## Touch devices support
Expand Down
1 change: 1 addition & 0 deletions doc/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Change log

## v0.6.3-dev (upcoming changes)

- fix [#540](https://github.com/gridstack/gridstack.js/issues/540) WebComponent support: CSS file now insert before grid instead of 'head'
- fix [#1143](https://github.com/gridstack/gridstack.js/issues/1143) nested grids with different `acceptWidgets` class
- fix [#1142](https://github.com/gridstack/gridstack.js/issues/1142) add/remove widget will also trigger change events when it should.
- optimized `change` callback to save original x,y,w,h values and only call those that changed [1148](https://github.com/gridstack/gridstack.js/pull/1148)
Expand Down
8 changes: 5 additions & 3 deletions src/gridstack.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
return Utils.sortBy(nodes, function(n) { return (n.x + n.y * column); });
},

createStylesheet: function(id) {
createStylesheet: function(id, parent) {
var style = document.createElement('style');
style.setAttribute('type', 'text/css');
style.setAttribute('data-gs-style-id', id);
Expand All @@ -84,7 +84,8 @@
} else {
style.appendChild(document.createTextNode(''));
}
document.getElementsByTagName('head')[0].appendChild(style);
if (!parent) { parent = document.getElementsByTagName('head')[0]; } // default to head
parent.insertBefore(style, parent.firstChild);
return style.sheet;
},

Expand Down Expand Up @@ -1068,7 +1069,8 @@
Utils.removeStylesheet(this._stylesId);
}
this._stylesId = 'gridstack-style-' + (Math.random() * 100000).toFixed();
this._styles = Utils.createStylesheet(this._stylesId);
// insert style to parent (instead of 'head') to support WebComponent
this._styles = Utils.createStylesheet(this._stylesId, this.container.get(0).parentNode);
if (this._styles !== null) {
this._styles._max = 0;
}
Expand Down