Skip to content

Commit e162d67

Browse files
committed
return this in api methods
1 parent ca30122 commit e162d67

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

src/api/dom.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ exports.$appendTo = function (target, cb, withTransition) {
1616
? append
1717
: transition.append
1818
insert(this, target, op, targetIsDetached, cb)
19+
return this
1920
}
2021

2122
/**
@@ -33,6 +34,7 @@ exports.$prependTo = function (target, cb, withTransition) {
3334
} else {
3435
this.$appendTo(target, cb, withTransition)
3536
}
37+
return this
3638
}
3739

3840
/**
@@ -50,6 +52,7 @@ exports.$before = function (target, cb, withTransition) {
5052
? before
5153
: transition.before
5254
insert(this, target, op, targetIsDetached, cb)
55+
return this
5356
}
5457

5558
/**
@@ -67,6 +70,7 @@ exports.$after = function (target, cb, withTransition) {
6770
} else {
6871
this.$appendTo(target.parentNode, cb, withTransition)
6972
}
73+
return this
7074
}
7175

7276
/**
@@ -101,6 +105,7 @@ exports.$remove = function (cb, withTransition) {
101105
: transition.remove
102106
op(this.$el, this, realCb)
103107
}
108+
return this
104109
}
105110

106111
/**

src/api/events.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ exports.$on = function (event, fn) {
1111
(this._events[event] || (this._events[event] = []))
1212
.push(fn)
1313
modifyListenerCount(this, event, 1)
14+
return this
1415
}
1516

1617
/**
@@ -29,6 +30,7 @@ exports.$once = function (event, fn) {
2930
}
3031
on.fn = fn
3132
this.$on(event, on)
33+
return this
3234
}
3335

3436
/**
@@ -52,15 +54,17 @@ exports.$off = function (event, fn) {
5254
}
5355
}
5456
this._events = {}
55-
return
57+
return this
5658
}
5759
// specific event
5860
cbs = this._events[event]
59-
if (!cbs) return
61+
if (!cbs) {
62+
return this
63+
}
6064
if (arguments.length === 1) {
6165
modifyListenerCount(this, event, -cbs.length)
6266
this._events[event] = null
63-
return
67+
return this
6468
}
6569
// specific handler
6670
var cb
@@ -73,6 +77,7 @@ exports.$off = function (event, fn) {
7377
break
7478
}
7579
}
80+
return this
7681
}
7782

7883
/**
@@ -102,6 +107,7 @@ exports.$emit = function (event) {
102107
}
103108
}
104109
}
110+
return this
105111
}
106112

107113
/**
@@ -125,6 +131,7 @@ exports.$broadcast = function (event) {
125131
}
126132
}
127133
}
134+
return this
128135
}
129136

130137
/**
@@ -142,6 +149,7 @@ exports.$dispatch = function () {
142149
? null
143150
: parent.$parent
144151
}
152+
return this
145153
}
146154

147155
/**

src/api/lifecycle.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ exports.$mount = function (el) {
3636
this._initDOMHooks()
3737
this.$once('hook:attached', ready)
3838
}
39+
return this
3940
}
4041

4142
/**

0 commit comments

Comments
 (0)