diff --git a/src/index.js b/src/index.js
index 08e0923..754907f 100644
--- a/src/index.js
+++ b/src/index.js
@@ -9,10 +9,9 @@ export default function h(name, attrs, ...children) {
// collapse it into the current object for MAGIC
let { name } = child;
if (name) {
- obj[name] = child;
+ obj[name] = obj[name] ? [obj[name], child].flat() : child
delete child.name;
- }
- else {
+ } else {
obj.value = child;
}
});
diff --git a/test/arrayFixture.json b/test/arrayFixture.json
new file mode 100644
index 0000000..8253a2d
--- /dev/null
+++ b/test/arrayFixture.json
@@ -0,0 +1,31 @@
+{
+ "name": "webpack",
+ "target": "web",
+ "watch": true,
+ "entry": {
+ "path": "src/index.js"
+ },
+ "resolve": {
+ "alias": [
+ {
+ "from": "react",
+ "to": "preact-compat"
+ },
+ {
+ "from": "react-dom",
+ "to": "preact-compat"
+ }
+ ]
+ },
+ "plugins": {
+ "uglify-js": {
+ "opts": {
+ "compression": true,
+ "mangle": false
+ }
+ },
+ "custom-plugin": {
+ "foo": "bar"
+ }
+ }
+}
diff --git a/test/index.js b/test/index.js
index 6bd5ff7..4edcf1b 100644
--- a/test/index.js
+++ b/test/index.js
@@ -1,33 +1,50 @@
import assert from 'assert';
import h from '../src';
import fixture from './fixture.json';
+import arrayFixture from './arrayFixture.json';
// example of an import'd plugin
-const CustomPlugin = config => ({
- ...config,
- name: 'custom-plugin'
+const CustomPlugin = (config) => ({
+ ...config,
+ name: 'custom-plugin'
});
-
var json = (
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
);
-
assert.deepEqual(json, fixture);
+var arrayJson = (
+
+
+
+
+
+
+
+
+
+
+
+);
+
+assert.deepEqual(arrayJson, arrayFixture);
+
console.log('✅ success');
process.exit(0);