Skip to content

Commit 8e81093

Browse files
committed
More checking to see if we can use shadowDom as expected
1 parent 597646a commit 8e81093

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

engine/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "goban-engine",
3-
"version": "8.3.48",
3+
"version": "8.3.49",
44
"description": "",
55
"main": "build/goban-engine.js",
66
"types": "build/engine/index.d.ts",

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "goban",
3-
"version": "8.3.48",
3+
"version": "8.3.49",
44
"description": "",
55
"main": "build/goban.js",
66
"types": "build/src/index.d.ts",

src/Goban/SVGRenderer.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,18 @@ declare let ResizeObserver: any;
5353

5454
const USE_CELL_RENDERER = true;
5555
// Shadow dom provided a bit of a performance boost, but older browsers don't support it yet.
56-
const USE_SHADOW_DOM = document.body.attachShadow !== undefined && CSSStyleSheet !== undefined;
56+
function canConstructStyleSheet() {
57+
try {
58+
new CSSStyleSheet();
59+
return true;
60+
} catch (e) {}
61+
62+
return false;
63+
}
64+
const USE_SHADOW_DOM =
65+
document.body.attachShadow !== undefined &&
66+
CSSStyleSheet !== undefined &&
67+
canConstructStyleSheet();
5768

5869
export interface SVGRendererGobanConfig extends GobanConfig {
5970
board_div?: HTMLElement;

0 commit comments

Comments
 (0)