Skip to content

Commit

Permalink
More checking to see if we can use shadowDom as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
anoek committed Sep 5, 2024
1 parent 597646a commit 8e81093
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion engine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "goban-engine",
"version": "8.3.48",
"version": "8.3.49",
"description": "",
"main": "build/goban-engine.js",
"types": "build/engine/index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "goban",
"version": "8.3.48",
"version": "8.3.49",
"description": "",
"main": "build/goban.js",
"types": "build/src/index.d.ts",
Expand Down
13 changes: 12 additions & 1 deletion src/Goban/SVGRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,18 @@ declare let ResizeObserver: any;

const USE_CELL_RENDERER = true;
// Shadow dom provided a bit of a performance boost, but older browsers don't support it yet.
const USE_SHADOW_DOM = document.body.attachShadow !== undefined && CSSStyleSheet !== undefined;
function canConstructStyleSheet() {
try {
new CSSStyleSheet();
return true;
} catch (e) {}

return false;
}
const USE_SHADOW_DOM =
document.body.attachShadow !== undefined &&
CSSStyleSheet !== undefined &&
canConstructStyleSheet();

export interface SVGRendererGobanConfig extends GobanConfig {
board_div?: HTMLElement;
Expand Down

0 comments on commit 8e81093

Please sign in to comment.