diff --git a/elements/TSpan.js b/elements/TSpan.js index 9cf073a1..0836d229 100644 --- a/elements/TSpan.js +++ b/elements/TSpan.js @@ -17,6 +17,22 @@ class TSpan extends Shape { textAnchor: PropTypes.oneOf(['start', 'middle', 'end']) }; + static childContextTypes = { + isInAParentText: React.PropTypes.bool + }; + + getChildContext() { + return { + isInAParentText: true + }; + }; + + getContextTypes() { + return { + isInAParentText: React.PropTypes.bool + }; + }; + setNativeProps = (...args) => { this.root.setNativeProps(...args); }; diff --git a/elements/Text.js b/elements/Text.js index f188d45b..56b635f6 100644 --- a/elements/Text.js +++ b/elements/Text.js @@ -17,6 +17,22 @@ class Text extends Shape { textAnchor: PropTypes.oneOf(['start', 'middle', 'end']) }; + static childContextTypes = { + isInAParentText: React.PropTypes.bool + }; + + getChildContext() { + return { + isInAParentText: true + }; + }; + + getContextTypes() { + return { + isInAParentText: React.PropTypes.bool + }; + }; + setNativeProps = (...args) => { this.root.setNativeProps(...args); }; diff --git a/lib/extract/extractText.js b/lib/extract/extractText.js index 55b0f639..67142490 100644 --- a/lib/extract/extractText.js +++ b/lib/extract/extractText.js @@ -96,11 +96,13 @@ export default function(props, container) { let { children } = props; let content = null; - if (typeof children === 'string') { + + if (typeof children === 'string' || typeof children === 'number') { + const childrenString = children.toString(); if (container) { - children = {children}; + children = {childrenString}; } else { - content = children; + content = childrenString; children = null; } } else if (Children.count(children) > 1) { @@ -121,7 +123,7 @@ export default function(props, container) { deltaX, deltaY, startOffset: (startOffset || 0).toString(), - positionX: _.isNil(x) ? null : x, - positionY: _.isNil(y) ? null : y + positionX: _.isNil(x) ? null : x.toString(), + positionY: _.isNil(y) ? null : y.toString() } }