Skip to content

Commit ef2249a

Browse files
committed
Move Plotly Shadow DOM Hack to helper, refs plotly/plotly.js#1433
1 parent d6da5ce commit ef2249a

File tree

2 files changed

+15
-12
lines changed

2 files changed

+15
-12
lines changed

elements/linechart.js

+3-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { withComponent, props } from 'skatejs';
22
import { colors } from '../lib/colors';
3-
import { parseValue } from '../lib//values';
3+
import { parseValue } from '../lib/values';
4+
import injectCss from '../lib/plotly-shadowdom';
45

56
const Component = withComponent();
67

@@ -56,17 +57,7 @@ class LineChart extends Component {
5657
root.removeChild(root.firstChild);
5758
}
5859
root.appendChild(render());
59-
60-
// Hack for Shadow DOM compat
61-
const styles = document.createElement('style');
62-
styles.innerText = `
63-
.js-plotly-plot .plotly .main-svg {
64-
position: absolute;
65-
top: 0;
66-
left: 0;
67-
pointer-events: none;
68-
}`;
69-
root.appendChild(styles);
60+
injectCss(root);
7061
}
7162

7263
render({ data, shape, width, height }) {

lib/plotly-shadowdom.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Hack for Shadow DOM compat
2+
export default function injectCss(root) {
3+
const styles = document.createElement('style');
4+
styles.appendChild(document.createTextNode(`
5+
.js-plotly-plot .plotly .main-svg {
6+
position: absolute;
7+
top: 0;
8+
left: 0;
9+
pointer-events: none;
10+
}`));
11+
root.appendChild(styles);
12+
};

0 commit comments

Comments
 (0)