Skip to content

Commit 1efe5dd

Browse files
committed
use more descriptive function names in stack traces
1 parent b9d8ad3 commit 1efe5dd

File tree

6 files changed

+38
-46
lines changed

6 files changed

+38
-46
lines changed

src/batcher.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ var internalQueueDepleted = false
1818
* Reset the batcher's state.
1919
*/
2020

21-
function reset () {
21+
function resetBatcherState () {
2222
queue = []
2323
userQueue = []
2424
has = {}
@@ -30,11 +30,11 @@ function reset () {
3030
* Flush both queues and run the watchers.
3131
*/
3232

33-
function flush () {
34-
run(queue)
33+
function flushBatcherQueue () {
34+
runBatcherQueue(queue)
3535
internalQueueDepleted = true
36-
run(userQueue)
37-
reset()
36+
runBatcherQueue(userQueue)
37+
resetBatcherState()
3838
}
3939

4040
/**
@@ -43,7 +43,7 @@ function flush () {
4343
* @param {Array} queue
4444
*/
4545

46-
function run (queue) {
46+
function runBatcherQueue (queue) {
4747
// do not cache length because more watchers might be pushed
4848
// as we run existing watchers
4949
for (var i = 0; i < queue.length; i++) {
@@ -92,7 +92,7 @@ exports.push = function (watcher) {
9292
// queue the flush
9393
if (!waiting) {
9494
waiting = true
95-
_.nextTick(flush)
95+
_.nextTick(flushBatcherQueue)
9696
}
9797
}
9898
}

src/directive.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ function Directive (name, el, vm, descriptor, def, host) {
4242
this._bind(def)
4343
}
4444

45-
var p = Directive.prototype
46-
4745
/**
4846
* Initialize the directive, mixin definition properties,
4947
* setup the watcher, call definition bind() and update()
@@ -52,7 +50,7 @@ var p = Directive.prototype
5250
* @param {Object} def
5351
*/
5452

55-
p._bind = function (def) {
53+
Directive.prototype._bind = function (def) {
5654
if (
5755
(this.name !== 'cloak' || this.vm._isCompiled) &&
5856
this.el && this.el.removeAttribute
@@ -113,7 +111,7 @@ p._bind = function (def) {
113111
* e.g. v-component="{{currentView}}"
114112
*/
115113

116-
p._checkDynamicLiteral = function () {
114+
Directive.prototype._checkDynamicLiteral = function () {
117115
var expression = this.expression
118116
if (expression && this.isLiteral) {
119117
var tokens = textParser.parse(expression)
@@ -137,7 +135,7 @@ p._checkDynamicLiteral = function () {
137135
* @return {Boolean}
138136
*/
139137

140-
p._checkStatement = function () {
138+
Directive.prototype._checkStatement = function () {
141139
var expression = this.expression
142140
if (
143141
expression && this.acceptStatement &&
@@ -163,7 +161,7 @@ p._checkStatement = function () {
163161
* @return {String}
164162
*/
165163

166-
p._checkParam = function (name) {
164+
Directive.prototype._checkParam = function (name) {
167165
var param = this.el.getAttribute(name)
168166
if (param !== null) {
169167
this.el.removeAttribute(name)
@@ -181,7 +179,7 @@ p._checkParam = function (name) {
181179
* @public
182180
*/
183181

184-
p.set = function (value) {
182+
Directive.prototype.set = function (value) {
185183
/* istanbul ignore else */
186184
if (this.twoWay) {
187185
this._withLock(function () {
@@ -202,7 +200,7 @@ p.set = function (value) {
202200
* @param {Function} fn
203201
*/
204202

205-
p._withLock = function (fn) {
203+
Directive.prototype._withLock = function (fn) {
206204
var self = this
207205
self._locked = true
208206
fn.call(self)
@@ -220,7 +218,7 @@ p._withLock = function (fn) {
220218
* @param {Function} handler
221219
*/
222220

223-
p.on = function (event, handler) {
221+
Directive.prototype.on = function (event, handler) {
224222
_.on(this.el, event, handler)
225223
;(this._listeners || (this._listeners = []))
226224
.push([event, handler])
@@ -230,7 +228,7 @@ p.on = function (event, handler) {
230228
* Teardown the watcher and call unbind.
231229
*/
232230

233-
p._teardown = function () {
231+
Directive.prototype._teardown = function () {
234232
if (this._bound) {
235233
this._bound = false
236234
if (this.unbind) {

src/observer/dep.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@ function Dep () {
1616
// watcher being evaluated at any time.
1717
Dep.target = null
1818

19-
var p = Dep.prototype
20-
2119
/**
2220
* Add a directive subscriber.
2321
*
2422
* @param {Directive} sub
2523
*/
2624

27-
p.addSub = function (sub) {
25+
Dep.prototype.addSub = function (sub) {
2826
this.subs.push(sub)
2927
}
3028

@@ -34,23 +32,23 @@ p.addSub = function (sub) {
3432
* @param {Directive} sub
3533
*/
3634

37-
p.removeSub = function (sub) {
35+
Dep.prototype.removeSub = function (sub) {
3836
this.subs.$remove(sub)
3937
}
4038

4139
/**
4240
* Add self as a dependency to the target watcher.
4341
*/
4442

45-
p.depend = function () {
43+
Dep.prototype.depend = function () {
4644
Dep.target.addDep(this)
4745
}
4846

4947
/**
5048
* Notify all subscribers of a new value.
5149
*/
5250

53-
p.notify = function () {
51+
Dep.prototype.notify = function () {
5452
// stablize the subscriber list first
5553
var subs = _.toArray(this.subs)
5654
for (var i = 0, l = subs.length; i < l; i++) {

src/observer/index.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ Observer.create = function (value, vm) {
6666

6767
// Instance methods
6868

69-
var p = Observer.prototype
70-
7169
/**
7270
* Walk through each property and convert them into
7371
* getter/setters. This method should only be called when
@@ -77,7 +75,7 @@ var p = Observer.prototype
7775
* @param {Object} obj
7876
*/
7977

80-
p.walk = function (obj) {
78+
Observer.prototype.walk = function (obj) {
8179
var keys = Object.keys(obj)
8280
var i = keys.length
8381
var key, prefix
@@ -98,7 +96,7 @@ p.walk = function (obj) {
9896
* @return {Dep|undefined}
9997
*/
10098

101-
p.observe = function (val) {
99+
Observer.prototype.observe = function (val) {
102100
return Observer.create(val)
103101
}
104102

@@ -108,7 +106,7 @@ p.observe = function (val) {
108106
* @param {Array} items
109107
*/
110108

111-
p.observeArray = function (items) {
109+
Observer.prototype.observeArray = function (items) {
112110
var i = items.length
113111
while (i--) {
114112
this.observe(items[i])
@@ -123,7 +121,7 @@ p.observeArray = function (items) {
123121
* @param {*} val
124122
*/
125123

126-
p.convert = function (key, val) {
124+
Observer.prototype.convert = function (key, val) {
127125
var ob = this
128126
var childOb = ob.observe(val)
129127
var dep = new Dep()
@@ -163,7 +161,7 @@ p.convert = function (key, val) {
163161
* @param {Vue} vm
164162
*/
165163

166-
p.addVm = function (vm) {
164+
Observer.prototype.addVm = function (vm) {
167165
(this.vms || (this.vms = [])).push(vm)
168166
}
169167

@@ -174,7 +172,7 @@ p.addVm = function (vm) {
174172
* @param {Vue} vm
175173
*/
176174

177-
p.removeVm = function (vm) {
175+
Observer.prototype.removeVm = function (vm) {
178176
this.vms.$remove(vm)
179177
}
180178

src/util/env.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ exports.nextTick = (function () {
5050
var callbacks = []
5151
var pending = false
5252
var timerFunc
53-
function handle () {
53+
function nextTickHandler () {
5454
pending = false
5555
var copies = callbacks.slice(0)
5656
callbacks = []
@@ -61,7 +61,7 @@ exports.nextTick = (function () {
6161
/* istanbul ignore if */
6262
if (typeof MutationObserver !== 'undefined') {
6363
var counter = 1
64-
var observer = new MutationObserver(handle)
64+
var observer = new MutationObserver(nextTickHandler)
6565
var textNode = document.createTextNode(counter)
6666
observer.observe(textNode, {
6767
characterData: true
@@ -80,6 +80,6 @@ exports.nextTick = (function () {
8080
callbacks.push(func)
8181
if (pending) return
8282
pending = true
83-
timerFunc(handle, 0)
83+
timerFunc(nextTickHandler, 0)
8484
}
8585
})()

src/watcher.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,13 @@ function Watcher (vm, expOrFn, cb, options) {
5757
this.queued = this.shallow = false
5858
}
5959

60-
var p = Watcher.prototype
61-
6260
/**
6361
* Add a dependency to this directive.
6462
*
6563
* @param {Dep} dep
6664
*/
6765

68-
p.addDep = function (dep) {
66+
Watcher.prototype.addDep = function (dep) {
6967
var newDeps = this.newDeps
7068
var old = this.deps
7169
if (_.indexOf(newDeps, dep) < 0) {
@@ -83,7 +81,7 @@ p.addDep = function (dep) {
8381
* Evaluate the getter, and re-collect dependencies.
8482
*/
8583

86-
p.get = function () {
84+
Watcher.prototype.get = function () {
8785
this.beforeGet()
8886
var vm = this.vm
8987
var value
@@ -125,7 +123,7 @@ p.get = function () {
125123
* @param {*} value
126124
*/
127125

128-
p.set = function (value) {
126+
Watcher.prototype.set = function (value) {
129127
var vm = this.vm
130128
if (this.filters) {
131129
value = vm._applyFilters(
@@ -150,7 +148,7 @@ p.set = function (value) {
150148
* Prepare for dependency collection.
151149
*/
152150

153-
p.beforeGet = function () {
151+
Watcher.prototype.beforeGet = function () {
154152
Dep.target = this
155153
this.newDeps = []
156154
}
@@ -159,7 +157,7 @@ p.beforeGet = function () {
159157
* Clean up for dependency collection.
160158
*/
161159

162-
p.afterGet = function () {
160+
Watcher.prototype.afterGet = function () {
163161
Dep.target = null
164162
var i = this.deps.length
165163
while (i--) {
@@ -179,7 +177,7 @@ p.afterGet = function () {
179177
* @param {Boolean} shallow
180178
*/
181179

182-
p.update = function (shallow) {
180+
Watcher.prototype.update = function (shallow) {
183181
if (this.lazy) {
184182
this.dirty = true
185183
} else if (this.sync || !config.async) {
@@ -207,7 +205,7 @@ p.update = function (shallow) {
207205
* Will be called by the batcher.
208206
*/
209207

210-
p.run = function () {
208+
Watcher.prototype.run = function () {
211209
if (this.active) {
212210
var value = this.get()
213211
if (
@@ -250,7 +248,7 @@ p.run = function () {
250248
* This only gets called for lazy watchers.
251249
*/
252250

253-
p.evaluate = function () {
251+
Watcher.prototype.evaluate = function () {
254252
// avoid overwriting another watcher that is being
255253
// collected.
256254
var current = Dep.target
@@ -263,7 +261,7 @@ p.evaluate = function () {
263261
* Depend on all deps collected by this watcher.
264262
*/
265263

266-
p.depend = function () {
264+
Watcher.prototype.depend = function () {
267265
var i = this.deps.length
268266
while (i--) {
269267
this.deps[i].depend()
@@ -274,7 +272,7 @@ p.depend = function () {
274272
* Remove self from all dependencies' subcriber list.
275273
*/
276274

277-
p.teardown = function () {
275+
Watcher.prototype.teardown = function () {
278276
if (this.active) {
279277
// remove self from vm's watcher list
280278
// we can skip this if the vm if being destroyed

0 commit comments

Comments
 (0)