Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: directive I/F consistency #2499

Merged
merged 1 commit into from
Mar 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 16 additions & 16 deletions src/directives/public/for.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const vFor = {
'leave-stagger'
],

bind: function () {
bind () {
// support "item in/of items" syntax
var inMatch = this.expression.match(/(.*) (?:in|of) (.*)/)
if (inMatch) {
Expand Down Expand Up @@ -78,7 +78,7 @@ const vFor = {
this.factory = new FragmentFactory(this.vm, this.el)
},

update: function (data) {
update (data) {
this.diff(data)
this.updateRef()
this.updateModel()
Expand All @@ -98,7 +98,7 @@ const vFor = {
* @param {Array} data
*/

diff: function (data) {
diff (data) {
// check if the Array was converted from an Object
var item = data[0]
var convertedFromObject = this.fromObject =
Expand Down Expand Up @@ -224,7 +224,7 @@ const vFor = {
* @return {Fragment}
*/

create: function (value, alias, index, key) {
create (value, alias, index, key) {
var host = this._host
// create iteration scope
var parentScope = this._scope || this.vm
Expand Down Expand Up @@ -258,7 +258,7 @@ const vFor = {
* Update the v-ref on owner vm.
*/

updateRef: function () {
updateRef () {
var ref = this.descriptor.ref
if (!ref) return
var hash = (this._scope || this.vm).$refs
Expand All @@ -279,7 +279,7 @@ const vFor = {
* parent <select>.
*/

updateModel: function () {
updateModel () {
if (this.isOption) {
var parent = this.start.parentNode
var model = parent && parent.__v_model
Expand All @@ -298,7 +298,7 @@ const vFor = {
* @param {Boolean} inDocument
*/

insert: function (frag, index, prevEl, inDocument) {
insert (frag, index, prevEl, inDocument) {
if (frag.staggerCb) {
frag.staggerCb.cancel()
frag.staggerCb = null
Expand Down Expand Up @@ -334,7 +334,7 @@ const vFor = {
* @param {Boolean} inDocument
*/

remove: function (frag, index, total, inDocument) {
remove (frag, index, total, inDocument) {
if (frag.staggerCb) {
frag.staggerCb.cancel()
frag.staggerCb = null
Expand Down Expand Up @@ -365,7 +365,7 @@ const vFor = {
* @param {Node} prevEl
*/

move: function (frag, prevEl) {
move (frag, prevEl) {
// fix a common issue with Sortable:
// if prevEl doesn't have nextSibling, this means it's
// been dragged after the end anchor. Just re-position
Expand All @@ -386,7 +386,7 @@ const vFor = {
* @param {String} [key]
*/

cacheFrag: function (value, frag, index, key) {
cacheFrag (value, frag, index, key) {
var trackByKey = this.params.trackBy
var cache = this.cache
var primitive = !isObject(value)
Expand Down Expand Up @@ -428,7 +428,7 @@ const vFor = {
* @return {Fragment}
*/

getCachedFrag: function (value, index, key) {
getCachedFrag (value, index, key) {
var trackByKey = this.params.trackBy
var primitive = !isObject(value)
var frag
Expand All @@ -455,7 +455,7 @@ const vFor = {
* @param {Fragment} frag
*/

deleteCachedFrag: function (frag) {
deleteCachedFrag (frag) {
var value = frag.raw
var trackByKey = this.params.trackBy
var scope = frag.scope
Expand Down Expand Up @@ -486,7 +486,7 @@ const vFor = {
* @param {String} type
*/

getStagger: function (frag, index, total, type) {
getStagger (frag, index, total, type) {
type = type + 'Stagger'
var trans = frag.node.__v_trans
var hooks = trans && trans.hooks
Expand All @@ -501,7 +501,7 @@ const vFor = {
* filters. This is passed to and called by the watcher.
*/

_preProcess: function (value) {
_preProcess (value) {
// regardless of type, store the un-filtered raw value.
this.rawValue = value
return value
Expand All @@ -516,7 +516,7 @@ const vFor = {
* the v-for to update when the source Object is mutated.
*/

_postProcess: function (value) {
_postProcess (value) {
if (isArray(value)) {
return value
} else if (isPlainObject(value)) {
Expand All @@ -541,7 +541,7 @@ const vFor = {
}
},

unbind: function () {
unbind () {
if (this.descriptor.ref) {
(this._scope || this.vm).$refs[this.descriptor.ref] = null
}
Expand Down
4 changes: 2 additions & 2 deletions src/directives/public/if.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default {
this.frag.before(this.anchor)
},

remove: function () {
remove () {
if (this.frag) {
this.frag.remove()
this.frag = null
Expand All @@ -74,7 +74,7 @@ export default {
}
},

unbind: function () {
unbind () {
if (this.frag) {
this.frag.destroy()
}
Expand Down