Skip to content

Commit 57742c3

Browse files
committed
fix indentation styles per eslint 1.5
1 parent 6bf49a0 commit 57742c3

File tree

6 files changed

+71
-52
lines changed

6 files changed

+71
-52
lines changed

src/api/data.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,15 @@ exports.$interpolate = function (text) {
132132
var tokens = textParser.parse(text)
133133
var vm = this
134134
if (tokens) {
135-
return tokens.length === 1
136-
? vm.$eval(tokens[0].value)
137-
: tokens.map(function (token) {
138-
return token.tag
139-
? vm.$eval(token.value)
140-
: token.value
141-
}).join('')
135+
if (tokens.length === 1) {
136+
return vm.$eval(tokens[0].value)
137+
} else {
138+
return tokens.map(function (token) {
139+
return token.tag
140+
? vm.$eval(token.value)
141+
: token.value
142+
}).join('')
143+
}
142144
} else {
143145
return text
144146
}

src/compiler/compile.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -724,22 +724,26 @@ function collectAttrDirective (name, value, options) {
724724
allOneTime = false
725725
}
726726
}
727+
var linker
728+
if (allOneTime) {
729+
linker = function (vm, el, scope) {
730+
el.setAttribute(name, (scope || vm).$interpolate(value))
731+
}
732+
} else {
733+
linker = function (vm, el, scope) {
734+
var exp = textParser.tokensToExp(tokens, (scope || vm))
735+
var desc = isClass
736+
? dirParser.parse(exp)[0]
737+
: dirParser.parse(name + ':' + exp)[0]
738+
if (isClass) {
739+
desc._rawClass = value
740+
}
741+
vm._bindDir(dirName, el, desc, def, undefined, scope)
742+
}
743+
}
727744
return {
728745
def: def,
729-
_link: allOneTime
730-
? function (vm, el, scope) {
731-
el.setAttribute(name, (scope || vm).$interpolate(value))
732-
}
733-
: function (vm, el, scope) {
734-
var exp = textParser.tokensToExp(tokens, (scope || vm))
735-
var desc = isClass
736-
? dirParser.parse(exp)[0]
737-
: dirParser.parse(name + ':' + exp)[0]
738-
if (isClass) {
739-
desc._rawClass = value
740-
}
741-
vm._bindDir(dirName, el, desc, def, undefined, scope)
742-
}
746+
_link: linker
743747
}
744748
}
745749
}

src/directive.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ var config = require('./config')
33
var Watcher = require('./watcher')
44
var textParser = require('./parsers/text')
55
var expParser = require('./parsers/expression')
6+
function noop () {}
67

78
/**
89
* A directive links a DOM element with a piece of data,
@@ -103,13 +104,15 @@ Directive.prototype._bind = function () {
103104
) {
104105
// wrapped updater for context
105106
var dir = this
106-
var update = this._update = this.update
107-
? function (val, oldVal) {
108-
if (!dir._locked) {
109-
dir.update(val, oldVal)
110-
}
107+
if (this.update) {
108+
this._update = function (val, oldVal) {
109+
if (!dir._locked) {
110+
dir.update(val, oldVal)
111111
}
112-
: function () {} // noop if no update is provided
112+
}
113+
} else {
114+
this._update = noop
115+
}
113116
// pre-process hook called before the value is piped
114117
// through the filters. used in v-repeat.
115118
var preProcess = this._preProcess
@@ -118,7 +121,7 @@ Directive.prototype._bind = function () {
118121
var watcher = this._watcher = new Watcher(
119122
this.vm,
120123
this._watcherExp,
121-
update, // callback
124+
this._update, // callback
122125
{
123126
filters: this.filters,
124127
twoWay: this.twoWay,

src/filters/array-filters.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@ exports.filterBy = function (arr, search, delimiter /* ...dataKeys */) {
2626
return prev.concat(cur)
2727
}, [])
2828
return arr.filter(function (item) {
29-
return keys.length
30-
? keys.some(function (key) {
31-
return contains(Path.get(item, key), search)
32-
})
33-
: contains(item, search)
29+
if (keys.length) {
30+
return keys.some(function (key) {
31+
return contains(Path.get(item, key), search)
32+
})
33+
} else {
34+
return contains(item, search)
35+
}
3436
})
3537
}
3638

src/parsers/template.js

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -156,22 +156,28 @@ function nodeToFragment (node) {
156156

157157
// Test for the presence of the Safari template cloning bug
158158
// https://bugs.webkit.org/show_bug.cgi?id=137755
159-
var hasBrokenTemplate = _.inBrowser
160-
? (function () {
161-
var a = document.createElement('div')
162-
a.innerHTML = '<template>1</template>'
163-
return !a.cloneNode(true).firstChild.innerHTML
164-
})()
165-
: false
159+
var hasBrokenTemplate = (function () {
160+
/* istanbul ignore else */
161+
if (_.inBrowser) {
162+
var a = document.createElement('div')
163+
a.innerHTML = '<template>1</template>'
164+
return !a.cloneNode(true).firstChild.innerHTML
165+
} else {
166+
return false
167+
}
168+
})()
166169

167170
// Test for IE10/11 textarea placeholder clone bug
168-
var hasTextareaCloneBug = _.inBrowser
169-
? (function () {
170-
var t = document.createElement('textarea')
171-
t.placeholder = 't'
172-
return t.cloneNode(true).value === 't'
173-
})()
174-
: false
171+
var hasTextareaCloneBug = (function () {
172+
/* istanbul ignore else */
173+
if (_.inBrowser) {
174+
var t = document.createElement('textarea')
175+
t.placeholder = 't'
176+
return t.cloneNode(true).value === 't'
177+
} else {
178+
return false
179+
}
180+
})()
175181

176182
/**
177183
* 1. Deal with Safari cloning nested <template> bug by

src/parsers/text.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,13 @@ exports.parse = function (text) {
106106
*/
107107

108108
exports.tokensToExp = function (tokens, vm) {
109-
return tokens.length > 1
110-
? tokens.map(function (token) {
111-
return formatToken(token, vm)
112-
}).join('+')
113-
: formatToken(tokens[0], vm, true)
109+
if (tokens.length > 1) {
110+
return tokens.map(function (token) {
111+
return formatToken(token, vm)
112+
}).join('+')
113+
} else {
114+
return formatToken(tokens[0], vm, true)
115+
}
114116
}
115117

116118
/**

0 commit comments

Comments
 (0)