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>
|
||||
|
||||
<script>
|
||||
let utterancesLoaded = false;
|
||||
|
||||
function setUtterancesTheme(theme) {
|
||||
let utterances = document.querySelector('.utterances iframe');
|
||||
if (utterances) {
|
||||
@ -31,10 +33,14 @@
|
||||
|
||||
addEventListener('message', event => {
|
||||
if (event.origin !== 'https://utteranc.es') return;
|
||||
|
||||
/// Called when Utterances is ready
|
||||
utterancesLoaded = true;
|
||||
setUtterancesTheme(document.documentElement.dataset.scheme)
|
||||
});
|
||||
|
||||
window.addEventListener('onColorSchemeChange', (e) => {
|
||||
if (!utterancesLoaded) return;
|
||||
setUtterancesTheme(e.detail)
|
||||
})
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user