From 1138ed7e04848b570a70e493b410902cfc4a9076 Mon Sep 17 00:00:00 2001 From: Evilebot Tnawi Date: Tue, 24 Dec 2019 11:20:58 +0300 Subject: [PATCH] fix: checking that the list of modules is an array (#448) --- src/runtime/injectStylesIntoStyleTag.js | 4 ++++ .../__snapshots__/injectStylesIntoStyleTag.test.js.snap | 2 ++ test/runtime/injectStylesIntoStyleTag.test.js | 6 ++++++ 3 files changed, 12 insertions(+) diff --git a/src/runtime/injectStylesIntoStyleTag.js b/src/runtime/injectStylesIntoStyleTag.js index 0c8c0e59..068827f3 100644 --- a/src/runtime/injectStylesIntoStyleTag.js +++ b/src/runtime/injectStylesIntoStyleTag.js @@ -47,6 +47,10 @@ const getTarget = (function getTarget() { })(); function addModulesToDom(id, list, options) { + if (Object.prototype.toString.call(list) !== '[object Array]') { + return; + } + id = options.base ? id + options.base : id; if (!stylesInDom[id]) { diff --git a/test/runtime/__snapshots__/injectStylesIntoStyleTag.test.js.snap b/test/runtime/__snapshots__/injectStylesIntoStyleTag.test.js.snap index b42479cb..16927a92 100644 --- a/test/runtime/__snapshots__/injectStylesIntoStyleTag.test.js.snap +++ b/test/runtime/__snapshots__/injectStylesIntoStyleTag.test.js.snap @@ -1,5 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`addStyle issue 447 1`] = `"Title

Hello world

"`; + exports[`addStyle should throw error with incorrect "insert" option 1`] = `"Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid."`; exports[`addStyle should throw error with invalid "insert" option 1`] = `"'#test><><><' is not a valid selector"`; diff --git a/test/runtime/injectStylesIntoStyleTag.test.js b/test/runtime/injectStylesIntoStyleTag.test.js index d5ea4808..eb75b1ce 100644 --- a/test/runtime/injectStylesIntoStyleTag.test.js +++ b/test/runtime/injectStylesIntoStyleTag.test.js @@ -706,4 +706,10 @@ describe('addStyle', () => { expect(document.documentElement.innerHTML).toMatchSnapshot(); }); + + it('issue 447', () => { + injectStylesIntoStyleTag(getId(), {}); + + expect(document.documentElement.innerHTML).toMatchSnapshot(); + }); });