From c028d89a3ea4cee0fe20ef9060b4b1ede9dd72c9 Mon Sep 17 00:00:00 2001 From: Maxime Quandalle Date: Mon, 14 Feb 2022 10:31:57 +0100 Subject: [PATCH] =?UTF-8?q?Simplifie=20l'int=C3=A9gration=20iframe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit L'insertion de l'iframe par le script ne dépend plus d'un identifiant présent dans le DOM. Permet également l'insertion de plusieurs iframes sur la même page, ce qui était impossible avant. --- site/source/iframe-integration-script.js | 8 +++----- site/source/pages/integration/Iframe.tsx | 7 +------ 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/site/source/iframe-integration-script.js b/site/source/iframe-integration-script.js index a3b301c3d..2492fae12 100644 --- a/site/source/iframe-integration-script.js +++ b/site/source/iframe-integration-script.js @@ -1,8 +1,6 @@ import { hexToHSL } from './hexToHSL' -let script = - document.getElementById('script-monentreprise') || - document.getElementById('script-simulateur-embauche'), +let script = document.currentScript, moduleName = script.dataset.module || 'simulateur-embauche', couleur = script.dataset.couleur && @@ -65,8 +63,8 @@ links.innerHTML = ` ` -script.parentNode.insertBefore(iframe, script) -script.parentNode.insertBefore(links, script) +script.before(iframe) +script.before(links) window.addEventListener('message', function (evt) { if (evt.data.kind === 'resize-height') { diff --git a/site/source/pages/integration/Iframe.tsx b/site/source/pages/integration/Iframe.tsx index da2bf2b09..54ba46c7d 100644 --- a/site/source/pages/integration/Iframe.tsx +++ b/site/source/pages/integration/Iframe.tsx @@ -333,12 +333,7 @@ function IntegrationCode({ `} > {'<'} - - script -
- id -
- ="script-simulateur-embauche" + script
data-module=" {module}"