Skip to content

Commit

Permalink
feat: add shadow dom support, backported from #890 (#892)
Browse files Browse the repository at this point in the history
- backported from PR #890 to support the creation of SlickGrid inside ShadowDOM
  • Loading branch information
ghiscoding authored Oct 30, 2023
1 parent e722456 commit 20565ad
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions slick.grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ if (typeof Slick === "undefined") {
ffMaxSupportedCssHeight: 6000000,
maxSupportedCssHeight: 1000000000,
sanitizer: undefined, // sanitize function, built in basic sanitizer is: Slick.RegexSanitizer(dirtyHtml)
logSanitizedHtml: false // log to console when sanitised - recommend true for testing of dev and production
logSanitizedHtml: false, // log to console when sanitised - recommend true for testing of dev and production
shadowRoot: undefined
};

var columnDefaults = {
Expand Down Expand Up @@ -2056,6 +2057,7 @@ if (typeof Slick === "undefined") {
_style = document.createElement('style');
_style.nonce = 'random-string';
document.head.appendChild(_style);
(options.shadowRoot || document.head).appendChild(_style);

const sheet = _style.sheet;
if (sheet) {
Expand All @@ -2081,7 +2083,7 @@ if (typeof Slick === "undefined") {
function getColumnCssRules(idx) {
var i;
if (!stylesheet) {
var sheets = document.styleSheets;
var sheets = (options.shadowRoot || document).styleSheets;
for (i = 0; i < sheets.length; i++) {
if ((sheets[i].ownerNode || sheets[i].owningElement) == _style) {
stylesheet = sheets[i];
Expand Down

0 comments on commit 20565ad

Please sign in to comment.