File tree Expand file tree Collapse file tree 9 files changed +22
-42
lines changed
test/unit/specs/directives Expand file tree Collapse file tree 9 files changed +22
-42
lines changed Original file line number Diff line number Diff line change @@ -21,9 +21,6 @@ exports.$addChild = function (opts, BaseCtor) {
2121 : BaseCtor . options . inherit
2222 if ( inherit ) {
2323 var ctors = parent . _childCtors
24- if ( ! ctors ) {
25- ctors = parent . _childCtors = { }
26- }
2724 ChildVue = ctors [ BaseCtor . cid ]
2825 if ( ! ChildVue ) {
2926 var optionName = BaseCtor . options . name
@@ -45,9 +42,6 @@ exports.$addChild = function (opts, BaseCtor) {
4542 opts . _parent = parent
4643 opts . _root = parent . $root
4744 var child = new ChildVue ( opts )
48- if ( ! this . _children ) {
49- this . _children = [ ]
50- }
5145 this . _children . push ( child )
5246 return child
5347}
Original file line number Diff line number Diff line change @@ -122,13 +122,11 @@ exports.$broadcast = function (event) {
122122 // then there's no need to broadcast.
123123 if ( ! this . _eventsCount [ event ] ) return
124124 var children = this . _children
125- if ( children ) {
126- for ( var i = 0 , l = children . length ; i < l ; i ++ ) {
127- var child = children [ i ]
128- child . $emit . apply ( child , arguments )
129- if ( ! child . _eventCancelled ) {
130- child . $broadcast . apply ( child , arguments )
131- }
125+ for ( var i = 0 , l = children . length ; i < l ; i ++ ) {
126+ var child = children [ i ]
127+ child . $emit . apply ( child , arguments )
128+ if ( ! child . _eventCancelled ) {
129+ child . $broadcast . apply ( child , arguments )
132130 }
133131 }
134132 return this
Original file line number Diff line number Diff line change @@ -53,17 +53,13 @@ module.exports = {
5353 compile : function ( template ) {
5454 var vm = this . vm
5555 var frag = templateParser . clone ( template )
56- var originalChildLength = vm . _children
57- ? vm . _children . length
58- : 0
56+ var originalChildLength = vm . _children . length
5957 this . unlink = this . linker
6058 ? this . linker ( vm , frag )
6159 : vm . $compile ( frag )
6260 transition . blockAppend ( frag , this . end , vm )
63- this . children = vm . _children
64- ? vm . _children . slice ( originalChildLength )
65- : null
66- if ( this . children && _ . inDoc ( vm . $el ) ) {
61+ this . children = vm . _children . slice ( originalChildLength )
62+ if ( this . children . length && _ . inDoc ( vm . $el ) ) {
6763 this . children . forEach ( function ( child ) {
6864 child . _callHook ( 'attached' )
6965 } )
Original file line number Diff line number Diff line change @@ -122,11 +122,9 @@ exports._destroy = function (remove, deferCleanup) {
122122 parent . _children . splice ( i , 1 )
123123 }
124124 // destroy all children.
125- if ( this . _children ) {
126- i = this . _children . length
127- while ( i -- ) {
128- this . _children [ i ] . $destroy ( )
129- }
125+ i = this . _children . length
126+ while ( i -- ) {
127+ this . _children [ i ] . $destroy ( )
130128 }
131129 // teardown parent linkers
132130 if ( this . _containerUnlinkFn ) {
Original file line number Diff line number Diff line change @@ -80,7 +80,6 @@ exports._initDOMHooks = function () {
8080function onAttached ( ) {
8181 this . _isAttached = true
8282 var children = this . _children
83- if ( ! children ) return
8483 for ( var i = 0 , l = children . length ; i < l ; i ++ ) {
8584 var child = children [ i ]
8685 if ( ! child . _isAttached && inDoc ( child . $el ) ) {
@@ -96,7 +95,6 @@ function onAttached () {
9695function onDetached ( ) {
9796 this . _isAttached = false
9897 var children = this . _children
99- if ( ! children ) return
10098 for ( var i = 0 , l = children . length ; i < l ; i ++ ) {
10199 var child = children [ i ]
102100 if ( child . _isAttached && ! inDoc ( child . $el ) ) {
Original file line number Diff line number Diff line change @@ -46,9 +46,8 @@ exports._init = function (options) {
4646 this . _isBeingDestroyed = false
4747
4848 // children
49- this . _children = // @type {Array }
50- this . _childCtors = null // @type {Object } - hash to cache
51- // child constructors
49+ this . _children = [ ]
50+ this . _childCtors = { }
5251
5352 // merge options.
5453 options = this . $options = mergeOptions (
Original file line number Diff line number Diff line change @@ -117,14 +117,11 @@ exports._digest = function () {
117117 this . _watcherList [ i ] . update ( )
118118 }
119119 var children = this . _children
120- var child
121- if ( children ) {
122- i = children . length
123- while ( i -- ) {
124- child = children [ i ]
125- if ( child . $options . inherit ) {
126- child . _digest ( )
127- }
120+ i = children . length
121+ while ( i -- ) {
122+ var child = children [ i ]
123+ if ( child . $options . inherit ) {
124+ child . _digest ( )
128125 }
129126 }
130127}
Original file line number Diff line number Diff line change @@ -189,7 +189,7 @@ if (_.inBrowser) {
189189 }
190190 } )
191191 expect ( el . textContent ) . toBe ( '' )
192- expect ( vm . _children ) . toBeNull ( )
192+ expect ( vm . _children . length ) . toBe ( 0 )
193193 expect ( vm . _directives . length ) . toBe ( 1 ) // v-if
194194 vm . ok = true
195195 _ . nextTick ( function ( ) {
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ if (_.inBrowser) {
2828 } )
2929 // lazy instantitation
3030 expect ( el . innerHTML ) . toBe ( wrap ( '' ) )
31- expect ( vm . _children ) . toBeNull ( )
31+ expect ( vm . _children . length ) . toBe ( 0 )
3232 vm . test = true
3333 _ . nextTick ( function ( ) {
3434 expect ( el . innerHTML ) . toBe ( wrap ( '<div><div>A</div><!--v-component--></div>' ) )
@@ -91,7 +91,7 @@ if (_.inBrowser) {
9191 } )
9292 vm . $appendTo ( document . body )
9393 expect ( el . innerHTML ) . toBe ( wrap ( '' ) )
94- expect ( vm . _children ) . toBeNull ( )
94+ expect ( vm . _children . length ) . toBe ( 0 )
9595 vm . ok = true
9696 _ . nextTick ( function ( ) {
9797 expect ( el . innerHTML ) . toBe ( wrap ( '<div>123</div><!--v-component-->' ) )
@@ -127,7 +127,7 @@ if (_.inBrowser) {
127127 }
128128 } )
129129 expect ( el . innerHTML ) . toBe ( wrap ( '' ) )
130- expect ( vm . _children ) . toBeNull ( )
130+ expect ( vm . _children . length ) . toBe ( 0 )
131131 // toggle if with lazy instantiation
132132 vm . ok = true
133133 _ . nextTick ( function ( ) {
You can’t perform that action at this time.
0 commit comments