@samitouri / QOS-React-2 / commits / e9c995974d

Port out bug fixes to ReactARTFiber (#9309)

D4616127 D4629747 D4631778

Ben Alpert committed Mar 31, 2017 at 16:13 UTC e9c995974de812db67777e5ca64697152bc30a3d
1 file changed +27 -7
src/renderers/art/ReactARTFiber.js
+27 -7
@@ -292,7 +292,7 @@ class RadialGradient {
292 }
293
294 applyFill(node) {
295 - node.fillRadial.apply(node, this.args);
295 + node.fillRadial.apply(node, this._args);
296 }
297 }
298
@@ -302,7 +302,7 @@ class Pattern {
302 }
303
304 applyFill(node) {
305 - node.fillImage.apply(node, this.args);
305 + node.fillImage.apply(node, this._args);
306 }
307 }
308
@@ -361,6 +361,30 @@ class Surface extends Component {
361 }
362 }
363
364 +class Text extends React.Component {
365 + constructor(props) {
366 + super(props);
367 + // We allow reading these props. Ideally we could expose the Text node as
368 + // ref directly.
369 + for (const key of ['height', 'width', 'x', 'y']) {
370 + Object.defineProperty(this, key, {
371 + get: function() {
372 + return this._text ? this._text[key] : undefined;
373 + },
374 + });
375 + }
376 + }
377 + render() {
378 + // This means you can't have children that render into strings...
379 + const T = TYPES.TEXT;
380 + return (
381 + <T {...this.props} ref={t => this._text = t}>
382 + {childrenAsString(this.props.children)}
383 + </T>
384 + );
385 + }
386 +}
387 +
388 /** ART Renderer */
389
390 const ARTRenderer = ReactFiberReconciler({
@@ -506,10 +530,6 @@ module.exports = {
530 RadialGradient,
531 Shape: TYPES.SHAPE,
532 Surface,
509 - Text: function Text(props) {
510 - // TODO: This means you can't have children that render into strings.
511 - const T = TYPES.TEXT;
512 - return <T {...props}>{childrenAsString(props.children)}</T>;
513 - },
533 + Text: Text,
534 Transform,
535 };