From e9c995974de812db67777e5ca64697152bc30a3d Mon Sep 17 00:00:00 2001 From: Ben Alpert Date: Fri, 31 Mar 2017 16:13:01 +0100 Subject: [PATCH] Port out bug fixes to ReactARTFiber (#9309) D4616127 D4629747 D4631778 --- src/renderers/art/ReactARTFiber.js | 34 ++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 7 deletions(-) diff --git a/src/renderers/art/ReactARTFiber.js b/src/renderers/art/ReactARTFiber.js index 86b04e5e1c..2aa02b151a 100644 --- a/src/renderers/art/ReactARTFiber.js +++ b/src/renderers/art/ReactARTFiber.js @@ -292,7 +292,7 @@ class RadialGradient { } applyFill(node) { - node.fillRadial.apply(node, this.args); + node.fillRadial.apply(node, this._args); } } @@ -302,7 +302,7 @@ class Pattern { } applyFill(node) { - node.fillImage.apply(node, this.args); + node.fillImage.apply(node, this._args); } } @@ -361,6 +361,30 @@ class Surface extends Component { } } +class Text extends React.Component { + constructor(props) { + super(props); + // We allow reading these props. Ideally we could expose the Text node as + // ref directly. + for (const key of ['height', 'width', 'x', 'y']) { + Object.defineProperty(this, key, { + get: function() { + return this._text ? this._text[key] : undefined; + }, + }); + } + } + render() { + // This means you can't have children that render into strings... + const T = TYPES.TEXT; + return ( + this._text = t}> + {childrenAsString(this.props.children)} + + ); + } +} + /** ART Renderer */ const ARTRenderer = ReactFiberReconciler({ @@ -506,10 +530,6 @@ module.exports = { RadialGradient, Shape: TYPES.SHAPE, Surface, - Text: function Text(props) { - // TODO: This means you can't have children that render into strings. - const T = TYPES.TEXT; - return {childrenAsString(props.children)}; - }, + Text: Text, Transform, };