From 9192f6b6dec402976959617e32242f987e29addd Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Mon, 26 Jun 2023 13:40:10 +0200 Subject: [PATCH] more resilient --- docs/src/modules/components/AdCarbon.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/src/modules/components/AdCarbon.js b/docs/src/modules/components/AdCarbon.js index dddb77f10ad3e1..c19ed0ef953c54 100644 --- a/docs/src/modules/components/AdCarbon.js +++ b/docs/src/modules/components/AdCarbon.js @@ -8,7 +8,16 @@ const CarbonRoot = styled('span')(({ theme }) => { const styles = adStylesObject['body-image'](theme); return { + '& > div': { + // The isolation logic of carbonads is broken. + // Once the script starts loading, it will asynchronous resolve, with no way to stop it. + // This leads to duplication of the ad. + // + // To solve the issue, we only display the #carbonads div + display: 'none', + }, '& #carbonads': { + display: 'block', ...styles.root, '& .carbon-img': styles.imgWrapper, '& img': styles.img, @@ -16,9 +25,6 @@ const CarbonRoot = styled('span')(({ theme }) => { '& .carbon-text': styles.description, '& .carbon-poweredby': styles.poweredby, }, - '& [id^=carbonads_]': { - display: 'none', - }, }; }); @@ -28,7 +34,9 @@ function AdCarbonImage() { React.useEffect(() => { // The isolation logic of carbonads is broken. // Once the script starts loading, it will asynchronous resolve, with no way to stop it. - // This leads to duplication of the ad. To solve the issue, we debounce the load action. + // This leads to duplication of the ad. + // + // To solve the issue, e.g. StrictModel double effect execution, we debounce the load action. const load = setTimeout(() => { const script = loadScript( 'https://cdn.carbonads.com/carbon.js?serve=CKYIL27L&placement=material-uicom',