Skip to content

Commit 850a7e7

Browse files
committed
_children -> $children
1 parent 1c9926f commit 850a7e7

File tree

14 files changed

+66
-66
lines changed

14 files changed

+66
-66
lines changed

src/api/events.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ exports.$broadcast = function (event) {
121121
// if no child has registered for this event,
122122
// then there's no need to broadcast.
123123
if (!this._eventsCount[event]) return
124-
var children = this._children
124+
var children = this.$children
125125
for (var i = 0, l = children.length; i < l; i++) {
126126
var child = children[i]
127127
child.$emit.apply(child, arguments)
@@ -171,4 +171,4 @@ function modifyListenerCount (vm, event, count) {
171171
(parent._eventsCount[event] || 0) + count
172172
parent = parent.$parent
173173
}
174-
}
174+
}

src/directives/if.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ module.exports = {
7979
var start = this.start.nextSibling
8080
var end = this.end
8181
var selfCompoents =
82-
vm._children.length &&
83-
vm._children.filter(contains)
82+
vm.$children.length &&
83+
vm.$children.filter(contains)
8484
var transComponents =
8585
vm._transCpnts &&
8686
vm._transCpnts.filter(contains)

src/instance/compile.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,17 @@ exports._destroy = function (remove, deferCleanup) {
127127
// if parent is not being destroyed as well.
128128
var parent = this.$parent
129129
if (parent && !parent._isBeingDestroyed) {
130-
parent._children.$remove(this)
130+
parent.$children.$remove(this)
131131
}
132132
// same for transclusion host.
133133
var host = this._host
134134
if (host && !host._isBeingDestroyed) {
135135
host._transCpnts.$remove(this)
136136
}
137137
// destroy all children.
138-
i = this._children.length
138+
i = this.$children.length
139139
while (i--) {
140-
this._children[i].$destroy()
140+
this.$children[i].$destroy()
141141
}
142142
// teardown props
143143
if (this._propsUnlinkFn) {
@@ -181,7 +181,7 @@ exports._cleanup = function () {
181181
this.$el =
182182
this.$parent =
183183
this.$root =
184-
this._children =
184+
this.$children =
185185
this._transCpnts =
186186
this._directives = null
187187
// call the last hook...

src/instance/events.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ exports._initDOMHooks = function () {
7979

8080
function onAttached () {
8181
this._isAttached = true
82-
this._children.forEach(callAttach)
82+
this.$children.forEach(callAttach)
8383
if (this._transCpnts.length) {
8484
this._transCpnts.forEach(callAttach)
8585
}
@@ -103,7 +103,7 @@ function callAttach (child) {
103103

104104
function onDetached () {
105105
this._isAttached = false
106-
this._children.forEach(callDetach)
106+
this.$children.forEach(callDetach)
107107
if (this._transCpnts.length) {
108108
this._transCpnts.forEach(callDetach)
109109
}
@@ -135,4 +135,4 @@ exports._callHook = function (hook) {
135135
}
136136
}
137137
this.$emit('hook:' + hook)
138-
}
138+
}

src/instance/init.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ exports._init = function (options) {
4545
this._unlinkFn = null
4646

4747
// children
48-
this._children = []
48+
this.$children = []
4949
this._childCtors = {}
5050

5151
// transcluded components that belong to the parent.
@@ -56,7 +56,7 @@ exports._init = function (options) {
5656

5757
// push self into parent / transclusion host
5858
if (this.$parent) {
59-
this.$parent._children.push(this)
59+
this.$parent.$children.push(this)
6060
}
6161
if (this._host) {
6262
this._host._transCpnts.push(this)

src/instance/scope.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ exports._digest = function () {
168168
while (i--) {
169169
this._watchers[i].update()
170170
}
171-
var children = this._children
171+
var children = this.$children
172172
i = children.length
173173
while (i--) {
174174
var child = children[i]

test/unit/specs/api/child_spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('Child API', function () {
2222
expect(child.a).toBeUndefined()
2323
expect(child.$parent).toBe(vm)
2424
expect(child.$root).toBe(vm)
25-
expect(vm._children.indexOf(child)).toBe(0)
25+
expect(vm.$children.indexOf(child)).toBe(0)
2626
expect(_.resolveAsset(child.$options, 'directives', 'test')).toBeTruthy()
2727
})
2828

@@ -76,4 +76,4 @@ describe('Child API', function () {
7676
expect(child.constructor.toString().match(/^function VueTest\s?\(/)).toBeTruthy()
7777
})
7878

79-
})
79+
})

test/unit/specs/api/lifecycle_spec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ if (_.inBrowser) {
164164
expect(vm.$el).toBeNull()
165165
expect(vm.$parent).toBeNull()
166166
expect(vm.$root).toBeNull()
167-
expect(vm._children).toBeNull()
167+
expect(vm.$children).toBeNull()
168168
expect(vm._directives).toBeNull()
169169
expect(Object.keys(vm._events).length).toBe(0)
170170
})
@@ -198,11 +198,11 @@ if (_.inBrowser) {
198198
var parent = new Vue()
199199
var child = parent.$addChild()
200200
var child2 = parent.$addChild()
201-
expect(parent._children.length).toBe(2)
201+
expect(parent.$children.length).toBe(2)
202202
child.$destroy()
203-
expect(parent._children.length).toBe(1)
203+
expect(parent.$children.length).toBe(1)
204204
child2.$destroy()
205-
expect(parent._children.length).toBe(0)
205+
expect(parent.$children.length).toBe(0)
206206
})
207207

208208
it('children', function () {
@@ -300,4 +300,4 @@ if (_.inBrowser) {
300300
})
301301

302302
})
303-
}
303+
}

test/unit/specs/compiler/compile_spec.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,9 @@ if (_.inBrowser) {
308308
}
309309
}
310310
})
311-
var dirs = vm._children[0]._directives
311+
var dirs = vm.$children[0]._directives
312312
expect(dirs.length).toBe(2)
313-
vm._children[0].$destroy()
313+
vm.$children[0].$destroy()
314314
var i = dirs.length
315315
while (i--) {
316316
expect(dirs[i]._bound).toBe(false)
@@ -333,10 +333,10 @@ if (_.inBrowser) {
333333
})
334334
expect(el.firstChild.style.display).toBe('')
335335
expect(vm._directives.length).toBe(2)
336-
expect(vm._children.length).toBe(1)
337-
vm._children[0].$destroy()
336+
expect(vm.$children.length).toBe(1)
337+
vm.$children[0].$destroy()
338338
expect(vm._directives.length).toBe(1)
339-
expect(vm._children.length).toBe(0)
339+
expect(vm.$children.length).toBe(0)
340340
})
341341

342342
it('should remove transcluded directives from parent when unlinking (component)', function () {
@@ -355,10 +355,10 @@ if (_.inBrowser) {
355355
})
356356
expect(vm.$el.textContent).toBe('parent')
357357
expect(vm._directives.length).toBe(2)
358-
expect(vm._children.length).toBe(1)
359-
vm._children[0].$destroy()
358+
expect(vm.$children.length).toBe(1)
359+
vm.$children[0].$destroy()
360360
expect(vm._directives.length).toBe(1)
361-
expect(vm._children.length).toBe(0)
361+
expect(vm.$children.length).toBe(0)
362362
})
363363

364364
it('should remove transcluded directives from parent when unlinking (v-if + component)', function (done) {
@@ -380,12 +380,12 @@ if (_.inBrowser) {
380380
})
381381
expect(vm.$el.textContent).toBe('parent')
382382
expect(vm._directives.length).toBe(3)
383-
expect(vm._children.length).toBe(1)
383+
expect(vm.$children.length).toBe(1)
384384
vm.ok = false
385385
_.nextTick(function () {
386386
expect(vm.$el.textContent).toBe('')
387387
expect(vm._directives.length).toBe(1)
388-
expect(vm._children.length).toBe(0)
388+
expect(vm.$children.length).toBe(0)
389389
done()
390390
})
391391
})

test/unit/specs/directives/component_spec.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,11 @@ if (_.inBrowser) {
234234
}
235235
})
236236
expect(el.textContent).toBe('')
237-
expect(vm._children.length).toBe(0)
237+
expect(vm.$children.length).toBe(0)
238238
expect(vm._directives.length).toBe(1) // v-if
239239
vm.ok = true
240240
_.nextTick(function () {
241-
expect(vm._children.length).toBe(1)
241+
expect(vm.$children.length).toBe(1)
242242
expect(vm._directives.length).toBe(3) // v-if, v-component, v-text
243243
expect(el.textContent).toBe('hello world')
244244
done()
@@ -274,7 +274,7 @@ if (_.inBrowser) {
274274
}
275275
})
276276
expect(el.textContent).toBe('')
277-
vm._children[0].$emit('ok')
277+
vm.$children[0].$emit('ok')
278278
expect(el.textContent).toBe('AAA')
279279
})
280280

@@ -294,12 +294,12 @@ if (_.inBrowser) {
294294
}
295295
}
296296
})
297-
vm._children[0].$emit('ok')
297+
vm.$children[0].$emit('ok')
298298
vm.view = 'view-b'
299299
_.nextTick(function () {
300300
expect(el.textContent).toBe('AAA')
301301
// old vm is already removed, this is the new vm
302-
vm._children[0].$emit('ok')
302+
vm.$children[0].$emit('ok')
303303
expect(el.textContent).toBe('BBB')
304304
done()
305305
})
@@ -403,12 +403,12 @@ if (_.inBrowser) {
403403
})
404404
vm.view = 'test2'
405405
_.nextTick(function () {
406-
expect(vm._children.length).toBe(2)
407-
var child = vm._children[0]
408-
var child2 = vm._children[1]
406+
expect(vm.$children.length).toBe(2)
407+
var child = vm.$children[0]
408+
var child2 = vm.$children[1]
409409
vm._directives[0].unbind()
410410
expect(vm._directives[0].cache).toBeNull()
411-
expect(vm._children.length).toBe(0)
411+
expect(vm.$children.length).toBe(0)
412412
expect(child._isDestroyed).toBe(true)
413413
expect(child2._isDestroyed).toBe(true)
414414
done()

0 commit comments

Comments
 (0)