Skip to content

Commit b70bffe

Browse files
committed
fix indentation styles per eslint 1.5
1 parent 2a41b3a commit b70bffe

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
@@ -120,13 +120,15 @@ exports.$interpolate = function (text) {
120120
var tokens = textParser.parse(text)
121121
var vm = this
122122
if (tokens) {
123-
return tokens.length === 1
124-
? vm.$eval(tokens[0].value)
125-
: tokens.map(function (token) {
126-
return token.tag
127-
? vm.$eval(token.value)
128-
: token.value
129-
}).join('')
123+
if (tokens.length === 1) {
124+
return vm.$eval(tokens[0].value)
125+
} else {
126+
return tokens.map(function (token) {
127+
return token.tag
128+
? vm.$eval(token.value)
129+
: token.value
130+
}).join('')
131+
}
130132
} else {
131133
return text
132134
}

src/compiler/compile.js

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -592,22 +592,26 @@ function collectAttrDirective (name, value, options) {
592592
allOneTime = false
593593
}
594594
}
595+
var linker
596+
if (allOneTime) {
597+
linker = function (vm, el) {
598+
el.setAttribute(name, vm.$interpolate(value))
599+
}
600+
} else {
601+
linker = function (vm, el) {
602+
var exp = textParser.tokensToExp(tokens, vm)
603+
var desc = isClass
604+
? dirParser.parse(exp)[0]
605+
: dirParser.parse(name + ':' + exp)[0]
606+
if (isClass) {
607+
desc._rawClass = value
608+
}
609+
vm._bindDir(dirName, el, desc, def)
610+
}
611+
}
595612
return {
596613
def: def,
597-
_link: allOneTime
598-
? function (vm, el) {
599-
el.setAttribute(name, vm.$interpolate(value))
600-
}
601-
: function (vm, el) {
602-
var exp = textParser.tokensToExp(tokens, vm)
603-
var desc = isClass
604-
? dirParser.parse(exp)[0]
605-
: dirParser.parse(name + ':' + exp)[0]
606-
if (isClass) {
607-
desc._rawClass = value
608-
}
609-
vm._bindDir(dirName, el, desc, def)
610-
}
614+
_link: linker
611615
}
612616
}
613617
}

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,
@@ -73,13 +74,15 @@ Directive.prototype._bind = function (def) {
7374
!this._checkStatement()) {
7475
// wrapped updater for context
7576
var dir = this
76-
var update = this._update = this.update
77-
? function (val, oldVal) {
78-
if (!dir._locked) {
79-
dir.update(val, oldVal)
80-
}
77+
if (this.update) {
78+
this._update = function (val, oldVal) {
79+
if (!dir._locked) {
80+
dir.update(val, oldVal)
8181
}
82-
: function () {} // noop if no update is provided
82+
}
83+
} else {
84+
this._update = noop
85+
}
8386
// pre-process hook called before the value is piped
8487
// through the filters. used in v-repeat.
8588
var preProcess = this._preProcess
@@ -88,7 +91,7 @@ Directive.prototype._bind = function (def) {
8891
var watcher = this._watcher = new Watcher(
8992
this.vm,
9093
this._watcherExp,
91-
update, // callback
94+
this._update, // callback
9295
{
9396
filters: this.filters,
9497
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
@@ -118,11 +118,13 @@ exports.parse = function (text) {
118118
*/
119119

120120
exports.tokensToExp = function (tokens, vm) {
121-
return tokens.length > 1
122-
? tokens.map(function (token) {
123-
return formatToken(token, vm)
124-
}).join('+')
125-
: formatToken(tokens[0], vm, true)
121+
if (tokens.length > 1) {
122+
return tokens.map(function (token) {
123+
return formatToken(token, vm)
124+
}).join('+')
125+
} else {
126+
return formatToken(tokens[0], vm, true)
127+
}
126128
}
127129

128130
/**

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy