fix(comment/utterances): the target origin mismatch recipient window's origin (#735)
This commit is contained in:
parent
3ff06fe033
commit
d382ca993d
@ -16,6 +16,8 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
let utterancesLoaded = false;
|
||||||
|
|
||||||
function setUtterancesTheme(theme) {
|
function setUtterancesTheme(theme) {
|
||||||
let utterances = document.querySelector('.utterances iframe');
|
let utterances = document.querySelector('.utterances iframe');
|
||||||
if (utterances) {
|
if (utterances) {
|
||||||
@ -31,10 +33,14 @@
|
|||||||
|
|
||||||
addEventListener('message', event => {
|
addEventListener('message', event => {
|
||||||
if (event.origin !== 'https://utteranc.es') return;
|
if (event.origin !== 'https://utteranc.es') return;
|
||||||
|
|
||||||
|
/// Called when Utterances is ready
|
||||||
|
utterancesLoaded = true;
|
||||||
setUtterancesTheme(document.documentElement.dataset.scheme)
|
setUtterancesTheme(document.documentElement.dataset.scheme)
|
||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener('onColorSchemeChange', (e) => {
|
window.addEventListener('onColorSchemeChange', (e) => {
|
||||||
|
if (!utterancesLoaded) return;
|
||||||
setUtterancesTheme(e.detail)
|
setUtterancesTheme(e.detail)
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user