From f715894caa941ed51ba1ab532b44aec9e0ad2508 Mon Sep 17 00:00:00 2001 From: Yannick Huard Date: Mon, 11 Mar 2019 09:26:00 +0100 Subject: [PATCH] fix: use appendChild instead of append for IE/Edge (#73) Should work in IE/Edge now --- .eslintrc.js | 3 +++ src/ec/packages/ec-component-accordion/accordion.story.js | 6 +++--- src/ec/packages/ec-component-breadcrumb/breadcrumb.story.js | 4 ++-- .../contextual-navigation.story.js | 4 ++-- src/ec/packages/ec-component-expandable/expandable.story.js | 4 ++-- src/ec/packages/ec-component-file/file.story.js | 4 ++-- utils/storybook-addon-code/src/index.js | 2 +- 7 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 2e25edf21..cac2de045 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -13,6 +13,9 @@ module.exports = { node: true, browser: true, }, + rules: { + 'unicorn/prefer-node-append': false, + }, overrides: [ { files: ['src/**/*.{story,test}.js'], diff --git a/src/ec/packages/ec-component-accordion/accordion.story.js b/src/ec/packages/ec-component-accordion/accordion.story.js index 4354b15f5..31bc3e00f 100644 --- a/src/ec/packages/ec-component-accordion/accordion.story.js +++ b/src/ec/packages/ec-component-accordion/accordion.story.js @@ -35,7 +35,7 @@ storiesOf('Components/Accordion', module) const htmlElement = document.createElement('div'); htmlElement.innerHTML = html.trim(); - demo.append(htmlElement.firstChild); + demo.appendChild(htmlElement.firstChild); const scriptElement = document.createElement('script'); scriptElement.innerHTML = ` @@ -44,9 +44,9 @@ storiesOf('Components/Accordion', module) for (var i = 0; i < elements.length; i += 1) { var accordion = new ECL.Accordion(elements[i]); accordion.init(); - } + } `; - demo.append(scriptElement); + demo.appendChild(scriptElement); return demo; }, diff --git a/src/ec/packages/ec-component-breadcrumb/breadcrumb.story.js b/src/ec/packages/ec-component-breadcrumb/breadcrumb.story.js index 069a99f65..d15652157 100644 --- a/src/ec/packages/ec-component-breadcrumb/breadcrumb.story.js +++ b/src/ec/packages/ec-component-breadcrumb/breadcrumb.story.js @@ -52,7 +52,7 @@ storiesOf('Components/Breadcrumb', module) const htmlElement = document.createElement('div'); htmlElement.innerHTML = html.trim(); - demo.append(htmlElement.firstChild); + demo.appendChild(htmlElement.firstChild); const scriptElement = document.createElement('script'); scriptElement.innerHTML = ` @@ -60,7 +60,7 @@ storiesOf('Components/Breadcrumb', module) var breadcrumb = new ECL.Breadcrumb(breadcrumbElement); breadcrumb.init(); `; - demo.append(scriptElement); + demo.appendChild(scriptElement); return demo; }, diff --git a/src/ec/packages/ec-component-contextual-navigation/contextual-navigation.story.js b/src/ec/packages/ec-component-contextual-navigation/contextual-navigation.story.js index b9eac9bf1..7fa610ad4 100644 --- a/src/ec/packages/ec-component-contextual-navigation/contextual-navigation.story.js +++ b/src/ec/packages/ec-component-contextual-navigation/contextual-navigation.story.js @@ -35,7 +35,7 @@ storiesOf('Components/Contextual Navigation', module) const htmlElement = document.createElement('div'); htmlElement.innerHTML = html.trim(); - demo.append(htmlElement.firstChild); + demo.appendChild(htmlElement.firstChild); const scriptElement = document.createElement('script'); scriptElement.innerHTML = ` @@ -43,7 +43,7 @@ storiesOf('Components/Contextual Navigation', module) var contextualNavigation = new ECL.ContextualNavigation(element); contextualNavigation.init(); `; - demo.append(scriptElement); + demo.appendChild(scriptElement); return demo; }, diff --git a/src/ec/packages/ec-component-expandable/expandable.story.js b/src/ec/packages/ec-component-expandable/expandable.story.js index f40a39f94..ebb994c4a 100644 --- a/src/ec/packages/ec-component-expandable/expandable.story.js +++ b/src/ec/packages/ec-component-expandable/expandable.story.js @@ -30,7 +30,7 @@ storiesOf('Components/Expandable', module) const htmlElement = document.createElement('div'); htmlElement.innerHTML = html.trim(); - demo.append(htmlElement.firstChild); + demo.appendChild(htmlElement.firstChild); const scriptElement = document.createElement('script'); scriptElement.innerHTML = ` @@ -38,7 +38,7 @@ storiesOf('Components/Expandable', module) var expandable = new ECL.Expandable(expandableElement); expandable.init(); `; - demo.append(scriptElement); + demo.appendChild(scriptElement); return demo; }, diff --git a/src/ec/packages/ec-component-file/file.story.js b/src/ec/packages/ec-component-file/file.story.js index 41e759d2a..aad55bf95 100644 --- a/src/ec/packages/ec-component-file/file.story.js +++ b/src/ec/packages/ec-component-file/file.story.js @@ -33,7 +33,7 @@ storiesOf('Components/File', module) const htmlElement = document.createElement('div'); htmlElement.innerHTML = html.trim(); - demo.append(htmlElement.firstChild); + demo.appendChild(htmlElement.firstChild); const scriptElement = document.createElement('script'); scriptElement.innerHTML = ` @@ -41,7 +41,7 @@ storiesOf('Components/File', module) var file = new ECL.FileDownload(fileElement); file.init(); `; - demo.append(scriptElement); + demo.appendChild(scriptElement); return demo; }, diff --git a/utils/storybook-addon-code/src/index.js b/utils/storybook-addon-code/src/index.js index e6b0ebf2f..3b3f5fd44 100644 --- a/utils/storybook-addon-code/src/index.js +++ b/utils/storybook-addon-code/src/index.js @@ -11,7 +11,7 @@ const withCode = makeDecorator({ code = story; } else if (story instanceof DocumentFragment) { const htmlElement = document.createElement('div'); - htmlElement.append(story.cloneNode(true)); + htmlElement.appendChild(story.cloneNode(true)); code = htmlElement.innerHTML; } else if (story instanceof Node) { code = story.outerHTML;