diff --git a/__tests__/__snapshots__/HTMLView-test.js.snap b/__tests__/__snapshots__/HTMLView-test.js.snap
index 8d779a0..2d784a0 100644
--- a/__tests__/__snapshots__/HTMLView-test.js.snap
+++ b/__tests__/__snapshots__/HTMLView-test.js.snap
@@ -33,9 +33,7 @@ exports[` can use a custom node class 1`] = `
style={
Array [
null,
- Array [
- Object {},
- ],
+ Object {},
]
}
>
@@ -57,10 +55,7 @@ exports[` can use a custom node class 1`] = `
style={
Array [
null,
- Array [
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
@@ -75,9 +70,7 @@ exports[` can use a custom node class 1`] = `
style={
Array [
null,
- Array [
- Object {},
- ],
+ Object {},
]
}
>
@@ -120,9 +113,7 @@ exports[` can use a custom renderer 1`] = `
style={
Array [
null,
- Array [
- Object {},
- ],
+ Object {},
]
}
>
@@ -185,9 +176,7 @@ exports[` can use custom node props 1`] = `
style={
Array [
null,
- Array [
- Object {},
- ],
+ Object {},
]
}
>
@@ -209,10 +198,7 @@ exports[` can use custom node props 1`] = `
style={
Array [
null,
- Array [
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
@@ -227,9 +213,7 @@ exports[` can use custom node props 1`] = `
style={
Array [
null,
- Array [
- Object {},
- ],
+ Object {},
]
}
>
@@ -258,9 +242,7 @@ exports[` should handle additional text nodes between list items 1`]
style={
Array [
null,
- Array [
- Object {},
- ],
+ Object {},
]
}
>
@@ -282,10 +264,7 @@ exports[` should handle additional text nodes between list items 1`]
style={
Array [
null,
- Array [
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
@@ -301,9 +280,7 @@ exports[` should handle additional text nodes between list items 1`]
style={
Array [
null,
- Array [
- Object {},
- ],
+ Object {},
]
}
>
@@ -325,10 +302,7 @@ exports[` should handle additional text nodes between list items 1`]
style={
Array [
null,
- Array [
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
@@ -344,9 +318,7 @@ exports[` should handle additional text nodes between list items 1`]
style={
Array [
null,
- Array [
- Object {},
- ],
+ Object {},
]
}
>
@@ -389,9 +361,7 @@ exports[` should not render extra linebreaks if configured not to 1`]
style={
Array [
null,
- Array [
- Object {},
- ],
+ Object {},
]
}
>
@@ -412,13 +382,10 @@ exports[` should not render extra linebreaks if configured not to 1`]
style={
Array [
null,
- Array [
- Object {
- "fontSize": 30,
- "fontWeight": "500",
- },
- Object {},
- ],
+ Object {
+ "fontSize": 30,
+ "fontWeight": "500",
+ },
]
}
>
@@ -432,9 +399,7 @@ exports[` should not render extra linebreaks if configured not to 1`]
style={
Array [
null,
- Array [
- Object {},
- ],
+ Object {},
]
}
>
@@ -455,10 +420,7 @@ exports[` should not render extra linebreaks if configured not to 1`]
style={
Array [
null,
- Array [
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
@@ -479,10 +441,7 @@ exports[` should not render extra linebreaks if configured not to 1`]
style={
Array [
null,
- Array [
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
@@ -498,9 +457,7 @@ exports[` should not render extra linebreaks if configured not to 1`]
style={
Array [
null,
- Array [
- Object {},
- ],
+ Object {},
]
}
>
@@ -596,13 +553,10 @@ exports[` should render an empty element 1`] = `
style={
Array [
null,
- Array [
- Object {
- "color": "#007AFF",
- "fontWeight": "500",
- },
- Object {},
- ],
+ Object {
+ "color": "#007AFF",
+ "fontWeight": "500",
+ },
]
}
>
@@ -639,10 +593,7 @@ exports[` should render ol numbers 1`] = `
style={
Array [
null,
- Array [
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
@@ -666,10 +617,7 @@ exports[` should render ol numbers 1`] = `
style={
Array [
null,
- Array [
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
@@ -714,9 +662,7 @@ exports[` should render shoddy html including headings, links, bold,
style={
Array [
null,
- Array [
- Object {},
- ],
+ Object {},
]
}
>
@@ -737,10 +683,7 @@ exports[` should render shoddy html including headings, links, bold,
style={
Array [
null,
- Array [
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
@@ -761,14 +704,10 @@ exports[` should render shoddy html including headings, links, bold,
style={
Array [
null,
- Array [
- Object {
- "fontSize": 30,
- "fontWeight": "500",
- },
- Object {},
- Object {},
- ],
+ Object {
+ "fontSize": 30,
+ "fontWeight": "500",
+ },
]
}
>
@@ -784,10 +723,7 @@ exports[` should render shoddy html including headings, links, bold,
style={
Array [
null,
- Array [
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
@@ -808,11 +744,7 @@ exports[` should render shoddy html including headings, links, bold,
style={
Array [
null,
- Array [
- Object {},
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
@@ -833,14 +765,9 @@ exports[` should render shoddy html including headings, links, bold,
style={
Array [
null,
- Array [
- Object {
- "fontStyle": "italic",
- },
- Object {},
- Object {},
- Object {},
- ],
+ Object {
+ "fontStyle": "italic",
+ },
]
}
>
@@ -862,17 +789,10 @@ exports[` should render shoddy html including headings, links, bold,
style={
Array [
null,
- Array [
- Object {
- "fontWeight": "500",
- },
- Object {
- "fontStyle": "italic",
- },
- Object {},
- Object {},
- Object {},
- ],
+ Object {
+ "fontStyle": "italic",
+ "fontWeight": "500",
+ },
]
}
>
@@ -892,10 +812,7 @@ exports[` should render shoddy html including headings, links, bold,
style={
Array [
null,
- Array [
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
@@ -916,11 +833,7 @@ exports[` should render shoddy html including headings, links, bold,
style={
Array [
null,
- Array [
- Object {},
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
@@ -941,15 +854,10 @@ exports[` should render shoddy html including headings, links, bold,
style={
Array [
null,
- Array [
- Object {
- "color": "#007AFF",
- "fontWeight": "500",
- },
- Object {},
- Object {},
- Object {},
- ],
+ Object {
+ "color": "#007AFF",
+ "fontWeight": "500",
+ },
]
}
>
@@ -963,11 +871,7 @@ exports[` should render shoddy html including headings, links, bold,
style={
Array [
null,
- Array [
- Object {},
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
@@ -985,10 +889,7 @@ exports[` should render shoddy html including headings, links, bold,
style={
Array [
null,
- Array [
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
@@ -1003,9 +904,7 @@ exports[` should render shoddy html including headings, links, bold,
style={
Array [
null,
- Array [
- Object {},
- ],
+ Object {},
]
}
>
@@ -1076,10 +975,7 @@ exports[` should render ul bullets 1`] = `
style={
Array [
null,
- Array [
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
@@ -1103,10 +999,7 @@ exports[` should render ul bullets 1`] = `
style={
Array [
null,
- Array [
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
diff --git a/example/__tests__/__snapshots__/Example-test.js.snap b/example/__tests__/__snapshots__/Example-test.js.snap
index b1fcde5..e662482 100644
--- a/example/__tests__/__snapshots__/Example-test.js.snap
+++ b/example/__tests__/__snapshots__/Example-test.js.snap
@@ -41,9 +41,7 @@ exports[` should render 1`] = `
style={
Array [
null,
- Array [
- Object {},
- ],
+ Object {},
]
}
>
@@ -64,10 +62,7 @@ exports[` should render 1`] = `
style={
Array [
null,
- Array [
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
@@ -95,16 +90,10 @@ exports[` should render 1`] = `
style={
Array [
null,
- Array [
- Object {
- "fontStyle": "italic",
- },
- Object {
- "fontWeight": "500",
- },
- Object {},
- Object {},
- ],
+ Object {
+ "fontStyle": "italic",
+ "fontWeight": "500",
+ },
]
}
>
@@ -119,10 +108,7 @@ exports[` should render 1`] = `
style={
Array [
null,
- Array [
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
@@ -143,11 +129,7 @@ exports[` should render 1`] = `
style={
Array [
null,
- Array [
- Object {},
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
@@ -168,14 +150,9 @@ exports[` should render 1`] = `
style={
Array [
null,
- Array [
- Object {
- "fontStyle": "italic",
- },
- Object {},
- Object {},
- Object {},
- ],
+ Object {
+ "fontStyle": "italic",
+ },
]
}
>
@@ -197,17 +174,10 @@ exports[` should render 1`] = `
style={
Array [
null,
- Array [
- Object {
- "fontWeight": "500",
- },
- Object {
- "fontStyle": "italic",
- },
- Object {},
- Object {},
- Object {},
- ],
+ Object {
+ "fontStyle": "italic",
+ "fontWeight": "500",
+ },
]
}
>
@@ -227,10 +197,7 @@ exports[` should render 1`] = `
style={
Array [
null,
- Array [
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
@@ -251,11 +218,7 @@ exports[` should render 1`] = `
style={
Array [
null,
- Array [
- Object {},
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
@@ -276,15 +239,10 @@ exports[` should render 1`] = `
style={
Array [
null,
- Array [
- Object {
- "color": "#007AFF",
- "fontWeight": "500",
- },
- Object {},
- Object {},
- Object {},
- ],
+ Object {
+ "color": "#007AFF",
+ "fontWeight": "500",
+ },
]
}
>
@@ -298,11 +256,7 @@ exports[` should render 1`] = `
style={
Array [
null,
- Array [
- Object {},
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
@@ -320,10 +274,7 @@ exports[` should render 1`] = `
style={
Array [
null,
- Array [
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
@@ -353,10 +304,7 @@ exports[` should render 1`] = `
style={
Array [
null,
- Array [
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
@@ -378,14 +326,10 @@ exports[` should render 1`] = `
style={
Array [
null,
- Array [
- Object {
- "fontSize": 36,
- "fontWeight": "500",
- },
- Object {},
- Object {},
- ],
+ Object {
+ "fontSize": 36,
+ "fontWeight": "500",
+ },
]
}
>
@@ -401,10 +345,7 @@ exports[` should render 1`] = `
style={
Array [
null,
- Array [
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
@@ -425,14 +366,10 @@ exports[` should render 1`] = `
style={
Array [
null,
- Array [
- Object {
- "fontSize": 30,
- "fontWeight": "500",
- },
- Object {},
- Object {},
- ],
+ Object {
+ "fontSize": 30,
+ "fontWeight": "500",
+ },
]
}
>
@@ -448,10 +385,7 @@ exports[` should render 1`] = `
style={
Array [
null,
- Array [
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
@@ -472,14 +406,10 @@ exports[` should render 1`] = `
style={
Array [
null,
- Array [
- Object {
- "fontSize": 24,
- "fontWeight": "500",
- },
- Object {},
- Object {},
- ],
+ Object {
+ "fontSize": 24,
+ "fontWeight": "500",
+ },
]
}
>
@@ -495,10 +425,7 @@ exports[` should render 1`] = `
style={
Array [
null,
- Array [
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
@@ -519,14 +446,10 @@ exports[` should render 1`] = `
style={
Array [
null,
- Array [
- Object {
- "fontSize": 18,
- "fontWeight": "500",
- },
- Object {},
- Object {},
- ],
+ Object {
+ "fontSize": 18,
+ "fontWeight": "500",
+ },
]
}
>
@@ -542,10 +465,7 @@ exports[` should render 1`] = `
style={
Array [
null,
- Array [
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
@@ -566,14 +486,10 @@ exports[` should render 1`] = `
style={
Array [
null,
- Array [
- Object {
- "fontSize": 14,
- "fontWeight": "500",
- },
- Object {},
- Object {},
- ],
+ Object {
+ "fontSize": 14,
+ "fontWeight": "500",
+ },
]
}
>
@@ -589,10 +505,7 @@ exports[` should render 1`] = `
style={
Array [
null,
- Array [
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
@@ -613,14 +526,10 @@ exports[` should render 1`] = `
style={
Array [
null,
- Array [
- Object {
- "fontSize": 12,
- "fontWeight": "500",
- },
- Object {},
- Object {},
- ],
+ Object {
+ "fontSize": 12,
+ "fontWeight": "500",
+ },
]
}
>
@@ -634,10 +543,7 @@ exports[` should render 1`] = `
style={
Array [
null,
- Array [
- Object {},
- Object {},
- ],
+ Object {},
]
}
>
@@ -670,9 +576,7 @@ exports[` should render 1`] = `
style={
Array [
null,
- Array [
- Object {},
- ],
+ Object {},
]
}
>
diff --git a/htmlToElement.js b/htmlToElement.js
index 99164b0..187371c 100644
--- a/htmlToElement.js
+++ b/htmlToElement.js
@@ -43,9 +43,10 @@ export default function htmlToElement(rawHtml, customOpts = {}, done) {
};
function inheritedStyle(parent) {
- if (!parent) { return null; }
- const style = [opts.styles[parent.name] || {}];
- return parent.parent ? style.concat(inheritedStyle(parent.parent)) : style;
+ if (!parent) return null;
+ const style = opts.styles[parent.name] || {};
+ const parentStyle = inheritedStyle(parent.parent) || {};
+ return {...parentStyle, ...style};
}
function domToElement(dom, parent) {