@@ -26,7 +26,7 @@ var Mode = require('art/modes/current');
2626var ReactComponent = require ( 'ReactComponent' ) ;
2727var ReactMount = require ( 'ReactMount' ) ;
2828var ReactMultiChild = require ( 'ReactMultiChild' ) ;
29- var ReactNativeComponent = require ( 'ReactNativeComponent ' ) ;
29+ var ReactDOMComponent = require ( 'ReactDOMComponent ' ) ;
3030
3131var ReactComponentMixin = ReactComponent . Mixin ;
3232
@@ -171,12 +171,17 @@ var ContainerMixin = merge(ReactMultiChild.Mixin, {
171171// Surface - Root node of all ART
172172
173173var Surface = createComponent (
174- ReactNativeComponent . Mixin ,
174+ ReactDOMComponent . Mixin ,
175175 ReactComponentMixin ,
176176 ContainerMixin , {
177177
178- mountComponent : function ( rootID , transaction ) {
179- ReactComponentMixin . mountComponent . call ( this , rootID , transaction ) ;
178+ mountComponent : function ( rootID , transaction , mountDepth ) {
179+ ReactComponentMixin . mountComponent . call (
180+ this ,
181+ rootID ,
182+ transaction ,
183+ mountDepth
184+ ) ;
180185 transaction . getReactOnDOMReady ( ) . enqueue ( this , this . componentDidMount ) ;
181186 // Temporary placeholder
182187 return '<div ' + ReactMount . ATTR_NAME + '="' + rootID + '"></div>' ;
@@ -207,7 +212,7 @@ var Surface = createComponent(
207212 // TODO: event listeners
208213 } ;
209214
210- // We hack the internals of ReactNativeComponent to only update some DOM
215+ // We hack the internals of ReactDOMComponent to only update some DOM
211216 // properties that won't override anything important that's internal to ART.
212217 this . props = nextPropsSubset ;
213218 this . _updateDOMProperties ( prevPropsSubset ) ;
@@ -476,22 +481,38 @@ var Shape = createComponent(RenderableMixin, {
476481var Text = createComponent ( RenderableMixin , {
477482
478483 mountComponent : function ( ) {
479- this . node = Mode . Text ( '' ) ;
480- this . applyTextProps ( BLANK_PROPS , this . props ) ;
484+ var props = this . props ;
485+ var newString = childrenAsString ( props . children ) ;
486+ this . node = Mode . Text ( newString , props . font , props . alignment , props . path ) ;
487+ this . _oldString = newString ;
488+ this . applyRenderableProps ( BLANK_PROPS , this . props ) ;
481489 return this . node ;
482490 } ,
483491
484- receiveProps : function ( props ) {
485- this . applyTextProps ( this . props , props ) ;
486- this . props = props ;
492+ isSameFont : function ( oldFont , newFont ) {
493+ if ( oldFont === newFont ) {
494+ return true ;
495+ }
496+ if ( typeof newFont === 'string' || typeof oldFont === 'string' ) {
497+ return false ;
498+ }
499+ return (
500+ newFont . fontSize === oldFont . fontSize &&
501+ newFont . fontStyle === oldFont . fontStyle &&
502+ newFont . fontVariant === oldFont . fontVariant &&
503+ newFont . fontWeight === oldFont . fontWeight &&
504+ newFont . fontFamily === oldFont . fontFamily
505+ ) ;
487506 } ,
488507
489- applyTextProps : function ( oldProps , props ) {
508+ receiveProps : function ( props ) {
509+ var oldProps = this . props ;
510+
490511 var oldString = this . _oldString ;
491512 var newString = childrenAsString ( props . children ) ;
492513
493514 if ( oldString !== newString ||
494- oldProps . font !== props . font ||
515+ ! this . isSameFont ( oldProps . font , props . font ) ||
495516 oldProps . alignment !== props . alignment ||
496517 oldProps . path !== props . path ) {
497518 this . node . draw (
@@ -500,8 +521,11 @@ var Text = createComponent(RenderableMixin, {
500521 props . alignment ,
501522 props . path
502523 ) ;
524+ this . _oldString = newString ;
503525 }
526+
504527 this . applyRenderableProps ( oldProps , props ) ;
528+ this . props = props ;
505529 }
506530
507531} ) ;
0 commit comments