Skip to content

Commit 1138ed7

Browse files
fix: checking that the list of modules is an array (#448)
1 parent aa418dd commit 1138ed7

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/runtime/injectStylesIntoStyleTag.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ const getTarget = (function getTarget() {
4747
})();
4848

4949
function addModulesToDom(id, list, options) {
50+
if (Object.prototype.toString.call(list) !== '[object Array]') {
51+
return;
52+
}
53+
5054
id = options.base ? id + options.base : id;
5155

5256
if (!stylesInDom[id]) {

test/runtime/__snapshots__/injectStylesIntoStyleTag.test.js.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3+
exports[`addStyle issue 447 1`] = `"<head><title>Title</title></head><body><h1>Hello world</h1></body>"`;
4+
35
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."`;
46

57
exports[`addStyle should throw error with invalid "insert" option 1`] = `"'#test><><><' is not a valid selector"`;

test/runtime/injectStylesIntoStyleTag.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,4 +706,10 @@ describe('addStyle', () => {
706706

707707
expect(document.documentElement.innerHTML).toMatchSnapshot();
708708
});
709+
710+
it('issue 447', () => {
711+
injectStylesIntoStyleTag(getId(), {});
712+
713+
expect(document.documentElement.innerHTML).toMatchSnapshot();
714+
});
709715
});

0 commit comments

Comments
 (0)