Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit cdc093a

Browse files
committed
reformated multiline trinary expressions to have a leading ?/:.
1 parent 00cc9eb commit cdc093a

File tree

8 files changed

+57
-48
lines changed

8 files changed

+57
-48
lines changed

src/Angular.js

+16-12
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,14 @@ var uppercase = function (string){ return isString(string) ? string.toUpperCase(
3030

3131

3232
var manualLowercase = function (s) {
33-
return isString(s) ? s.replace(/[A-Z]/g,
34-
function (ch) {return fromCharCode(ch.charCodeAt(0) | 32); }) : s;
33+
return isString(s)
34+
? s.replace(/[A-Z]/g, function (ch) {return fromCharCode(ch.charCodeAt(0) | 32); })
35+
: s;
3536
};
3637
var manualUppercase = function (s) {
37-
return isString(s) ? s.replace(/[a-z]/g,
38-
function (ch) {return fromCharCode(ch.charCodeAt(0) & ~32); }) : s;
38+
return isString(s)
39+
? s.replace(/[a-z]/g, function (ch) {return fromCharCode(ch.charCodeAt(0) & ~32); })
40+
: s;
3941
};
4042

4143

@@ -89,7 +91,9 @@ var _undefined = undefined,
8991
jQuery, // delay binding
9092
slice = Array.prototype.slice,
9193
push = Array.prototype.push,
92-
error = window[$console] ? bind(window[$console], window[$console]['error'] || noop) : noop,
94+
error = window[$console]
95+
? bind(window[$console], window[$console]['error'] || noop)
96+
: noop,
9397

9498
/** @name angular */
9599
angular = window[$angular] || (window[$angular] = {}),
@@ -417,13 +421,13 @@ function isElement(node) {
417421
*/
418422
function HTML(html, option) {
419423
this.html = html;
420-
this.get = lowercase(option) == 'unsafe' ?
421-
valueFn(html) :
422-
function htmlSanitize() {
423-
var buf = [];
424-
htmlParser(html, htmlSanitizeWriter(buf));
425-
return buf.join('');
426-
};
424+
this.get = lowercase(option) == 'unsafe'
425+
? valueFn(html)
426+
: function htmlSanitize() {
427+
var buf = [];
428+
htmlParser(html, htmlSanitizeWriter(buf));
429+
return buf.join('');
430+
};
427431
}
428432

429433
if (msie) {

src/apis.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -637,8 +637,9 @@ var angularArray = {
637637
return 0;
638638
}
639639
function reverse(comp, descending) {
640-
return toBoolean(descending) ?
641-
function(a,b){return comp(b,a);} : comp;
640+
return toBoolean(descending)
641+
? function(a,b){return comp(b,a);}
642+
: comp;
642643
}
643644
function compare(v1, v2){
644645
var t1 = typeof v1;

src/directives.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -243,15 +243,17 @@ function compileBindTemplate(template){
243243
var bindings = [];
244244
forEach(parseBindings(template), function(text){
245245
var exp = binding(text);
246-
bindings.push(exp ? function(element){
247-
var error, value = this.$tryEval(exp, function(e){
248-
error = toJson(e);
249-
});
250-
elementError(element, NG_EXCEPTION, error);
251-
return error ? error : value;
252-
} : function() {
253-
return text;
254-
});
246+
bindings.push(exp
247+
? function(element){
248+
var error, value = this.$tryEval(exp, function(e){
249+
error = toJson(e);
250+
});
251+
elementError(element, NG_EXCEPTION, error);
252+
return error ? error : value;
253+
}
254+
: function() {
255+
return text;
256+
});
255257
});
256258
bindTemplateCache[template] = fn = function(element, prettyPrintJson){
257259
var parts = [], self = this,

src/jqLite.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
var jqCache = {},
66
jqName = 'ng-' + new Date().getTime(),
77
jqId = 1,
8-
addEventListenerFn = (window.document.addEventListener ?
9-
function(element, type, fn) {element.addEventListener(type, fn, false);} :
10-
function(element, type, fn) {element.attachEvent('on' + type, fn);}),
11-
removeEventListenerFn = (window.document.removeEventListener ?
12-
function(element, type, fn) {element.removeEventListener(type, fn, false); } :
13-
function(element, type, fn) {element.detachEvent('on' + type, fn); });
8+
addEventListenerFn = (window.document.addEventListener
9+
? function(element, type, fn) {element.addEventListener(type, fn, false);}
10+
: function(element, type, fn) {element.attachEvent('on' + type, fn);}),
11+
removeEventListenerFn = (window.document.removeEventListener
12+
? function(element, type, fn) {element.removeEventListener(type, fn, false); }
13+
: function(element, type, fn) {element.detachEvent('on' + type, fn); });
1414

1515
function jqNextId() { return (jqId++); }
1616

src/parser.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ function lex(text, parseStringsForObjects){
107107
function throwError(error, start, end) {
108108
end = end || index;
109109
throw Error("Lexer Error: " + error + " at column" +
110-
(isDefined(start) ?
111-
"s " + start + "-" + index + " [" + text.substring(start, end) + "]" :
112-
" " + end) +
110+
(isDefined(start)
111+
? "s " + start + "-" + index + " [" + text.substring(start, end) + "]"
112+
: " " + end) +
113113
" in expression [" + text + "].");
114114
}
115115

@@ -199,8 +199,9 @@ function lex(text, parseStringsForObjects){
199199
index++;
200200
tokens.push({index:start, text:rawString, string:string, json:true,
201201
fn:function(){
202-
return (string.length == dateParseLength) ?
203-
angular['String']['toDate'](string) : string;
202+
return (string.length == dateParseLength)
203+
? angular['String']['toDate'](string)
204+
: string;
204205
}});
205206
return;
206207
} else {
@@ -588,9 +589,9 @@ function parser(text, json){
588589
}
589590
var fnPtr = fn(self) || noop;
590591
// IE stupidity!
591-
return fnPtr.apply ?
592-
fnPtr.apply(self, args) :
593-
fnPtr(args[0], args[1], args[2], args[3], args[4]);
592+
return fnPtr.apply
593+
? fnPtr.apply(self, args)
594+
: fnPtr(args[0], args[1], args[2], args[3], args[4]);
594595
};
595596
}
596597

src/scenario/Scenario.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,9 @@ function browserTrigger(element, type) {
309309
*/
310310
_jQuery.fn.bindings = function(name) {
311311
function contains(text, value) {
312-
return value instanceof RegExp ?
313-
value.test(text) :
314-
text && text.indexOf(value) >= 0;
312+
return value instanceof RegExp
313+
? value.test(text)
314+
: text && text.indexOf(value) >= 0;
315315
}
316316
var result = [];
317317
this.find('.ng-binding:visible').each(function() {

src/validators.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,9 @@ extend(angularValidator, {
181181
return (date &&
182182
date.getFullYear() == fields[3] &&
183183
date.getMonth() == fields[1]-1 &&
184-
date.getDate() == fields[2]) ?
185-
_null : "Value is not a date. (Expecting format: 12/31/2009).";
184+
date.getDate() == fields[2])
185+
? _null
186+
: "Value is not a date. (Expecting format: 12/31/2009).";
186187
},
187188

188189
/**

src/widgets.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,9 @@ function valueAccessor(scope, element) {
337337
invalidWidgets.markValid(element);
338338
} else {
339339
var error, validateScope = inherit(scope, {$element:element});
340-
error = required && !value ?
341-
'Required' :
342-
(value ? validator(validateScope, value) : _null);
340+
error = required && !value
341+
? 'Required'
342+
: (value ? validator(validateScope, value) : _null);
343343
elementError(element, NG_VALIDATION_ERROR, error);
344344
lastError = error;
345345
if (error) {
@@ -940,9 +940,9 @@ angularWidget("@ng:repeat", function(expression, element){
940940
childScope[valueIdent] = collection[key];
941941
if (keyIdent) childScope[keyIdent] = key;
942942
childScope.$index = index;
943-
childScope.$position = index == 0 ?
944-
'first' :
945-
(index == collectionLength - 1 ? 'last' : 'middle');
943+
childScope.$position = index == 0
944+
? 'first'
945+
: (index == collectionLength - 1 ? 'last' : 'middle');
946946
lastElement.after(cloneElement = element.cloneNode());
947947
cloneElement.attr('ng:repeat-index', index);
948948
linker(childScope, cloneElement);

0 commit comments

Comments
 (0)