@@ -51,7 +51,6 @@ function createComponent(name) {
51
51
this . listeners = null ;
52
52
this . _mountImage = null ;
53
53
this . _renderedChildren = null ;
54
- this . _mostRecentlyPlacedChild = null ;
55
54
} ;
56
55
ReactARTComponent . displayName = name ;
57
56
for ( var i = 1 , l = arguments . length ; i < l ; i ++ ) {
@@ -63,6 +62,22 @@ function createComponent(name) {
63
62
64
63
// ContainerMixin for components that can hold ART nodes
65
64
65
+ function injectAfter ( parentNode , referenceNode , node ) {
66
+ var beforeNode ;
67
+ if ( referenceNode == null ) {
68
+ // node is supposed to be first.
69
+ beforeNode = parentNode . firstChild ;
70
+ } else {
71
+ // node is supposed to be after referenceNode.
72
+ beforeNode = referenceNode . nextSibling ;
73
+ }
74
+ if ( beforeNode ) {
75
+ node . injectBefore ( beforeNode ) ;
76
+ } else {
77
+ node . inject ( parentNode ) ;
78
+ }
79
+ }
80
+
66
81
var ContainerMixin = assign ( { } , ReactMultiChild . Mixin , {
67
82
68
83
/**
@@ -72,29 +87,9 @@ var ContainerMixin = assign({}, ReactMultiChild.Mixin, {
72
87
* @param {number } toIndex Destination index of the element.
73
88
* @protected
74
89
*/
75
- moveChild : function ( child , toIndex ) {
90
+ moveChild : function ( child , afterNode , toIndex , lastIndex ) {
76
91
var childNode = child . _mountImage ;
77
- var mostRecentlyPlacedChild = this . _mostRecentlyPlacedChild ;
78
- if ( mostRecentlyPlacedChild == null ) {
79
- // I'm supposed to be first.
80
- if ( childNode . previousSibling ) {
81
- if ( this . node . firstChild ) {
82
- childNode . injectBefore ( this . node . firstChild ) ;
83
- } else {
84
- childNode . inject ( this . node ) ;
85
- }
86
- }
87
- } else {
88
- // I'm supposed to be after the previous one.
89
- if ( mostRecentlyPlacedChild . nextSibling !== childNode ) {
90
- if ( mostRecentlyPlacedChild . nextSibling ) {
91
- childNode . injectBefore ( mostRecentlyPlacedChild . nextSibling ) ;
92
- } else {
93
- childNode . inject ( this . node ) ;
94
- }
95
- }
96
- }
97
- this . _mostRecentlyPlacedChild = childNode ;
92
+ injectAfter ( this . node , afterNode , childNode ) ;
98
93
} ,
99
94
100
95
/**
@@ -107,23 +102,7 @@ var ContainerMixin = assign({}, ReactMultiChild.Mixin, {
107
102
*/
108
103
createChild : function ( child , afterNode , childNode ) {
109
104
child . _mountImage = childNode ;
110
- var mostRecentlyPlacedChild = this . _mostRecentlyPlacedChild ;
111
- if ( mostRecentlyPlacedChild == null ) {
112
- // I'm supposed to be first.
113
- if ( this . node . firstChild ) {
114
- childNode . injectBefore ( this . node . firstChild ) ;
115
- } else {
116
- childNode . inject ( this . node ) ;
117
- }
118
- } else {
119
- // I'm supposed to be after the previous one.
120
- if ( mostRecentlyPlacedChild . nextSibling ) {
121
- childNode . injectBefore ( mostRecentlyPlacedChild . nextSibling ) ;
122
- } else {
123
- childNode . inject ( this . node ) ;
124
- }
125
- }
126
- this . _mostRecentlyPlacedChild = childNode ;
105
+ injectAfter ( this . node , afterNode , childNode ) ;
127
106
} ,
128
107
129
108
/**
@@ -154,7 +133,6 @@ var ContainerMixin = assign({}, ReactMultiChild.Mixin, {
154
133
* @override {ReactMultiChild.Mixin.updateChildren}
155
134
*/
156
135
updateChildren : function ( nextChildren , transaction , context ) {
157
- this . _mostRecentlyPlacedChild = null ;
158
136
this . _updateChildren ( nextChildren , transaction , context ) ;
159
137
} ,
160
138
@@ -273,6 +251,7 @@ var NodeMixin = {
273
251
} ,
274
252
275
253
getNativeNode : function ( ) {
254
+ return this . node ;
276
255
} ,
277
256
278
257
getPublicInstance : function ( ) {
0 commit comments