From 5ea7a05a3c4b77a6c8c96ff79165277ec466250d Mon Sep 17 00:00:00 2001 From: Tvrqvoise Date: Thu, 28 Jun 2018 10:01:38 -0500 Subject: [PATCH] Allow the root node to be customized via 'rules' --- src/lib/AstRenderer.js | 7 ++----- src/lib/renderRules.js | 4 ++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/lib/AstRenderer.js b/src/lib/AstRenderer.js index 532e0cf7..34079687 100644 --- a/src/lib/AstRenderer.js +++ b/src/lib/AstRenderer.js @@ -2,10 +2,6 @@ import React, { Component, PropTypes } from "react"; import { Text, View } from "react-native"; import getUniqueID from "./util/getUniqueID"; -export function rootRenderRule(children, styles) { - return {children}; -} - /** * */ @@ -66,6 +62,7 @@ export default class AstRenderer { */ render = nodes => { const children = nodes.map(value => this.renderNode(value, [])); - return rootRenderRule(children, this._style); + const root = { type: "root", key: getUniqueID() }; + return this.getRenderFunction(root.type)(root, children, null, this._style); }; } diff --git a/src/lib/renderRules.js b/src/lib/renderRules.js index 67a180c5..932f7e5f 100644 --- a/src/lib/renderRules.js +++ b/src/lib/renderRules.js @@ -7,6 +7,10 @@ import hasParents from './util/hasParents'; import applyStyle from './util/applyStyle'; const renderRules = { + root: (node, children, parent, styles) => ( + { children } + ), + // when unknown elements are introduced, so it wont break unknown: (node, children, parent, styles) => { return (