@@ -79,12 +79,21 @@ exports._initDOMHooks = function () {
7979
8080function onAttached ( ) {
8181 this . _isAttached = true
82- var children = this . _children
83- for ( var i = 0 , l = children . length ; i < l ; i ++ ) {
84- var child = children [ i ]
85- if ( ! child . _isAttached && inDoc ( child . $el ) ) {
86- child . _callHook ( 'attached' )
87- }
82+ this . _children . forEach ( callAttach )
83+ if ( this . _transCpnts ) {
84+ this . _transCpnts . forEach ( callAttach )
85+ }
86+ }
87+
88+ /**
89+ * Iterator to call attached hook
90+ *
91+ * @param {Vue } child
92+ */
93+
94+ function callAttach ( child ) {
95+ if ( ! child . _isAttached && inDoc ( child . $el ) ) {
96+ child . _callHook ( 'attached' )
8897 }
8998}
9099
@@ -94,12 +103,21 @@ function onAttached () {
94103
95104function onDetached ( ) {
96105 this . _isAttached = false
97- var children = this . _children
98- for ( var i = 0 , l = children . length ; i < l ; i ++ ) {
99- var child = children [ i ]
100- if ( child . _isAttached && ! inDoc ( child . $el ) ) {
101- child . _callHook ( 'detached' )
102- }
106+ this . _children . forEach ( callDetach )
107+ if ( this . _transCpnts ) {
108+ this . _transCpnts . forEach ( callDetach )
109+ }
110+ }
111+
112+ /**
113+ * Iterator to call detached hook
114+ *
115+ * @param {Vue } child
116+ */
117+
118+ function callDetach ( child ) {
119+ if ( child . _isAttached && ! inDoc ( child . $el ) ) {
120+ child . _callHook ( 'detached' )
103121 }
104122}
105123
0 commit comments