From cf8c05a091a9b192367d60093100b5f412342e57 Mon Sep 17 00:00:00 2001 From: Wladimir Coka Date: Thu, 21 Nov 2013 16:31:27 -0500 Subject: [PATCH 1/5] refactor($compile): improve readability on conditional assignment Use ternary operator instead of if statement --- src/ng/compile.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/ng/compile.js b/src/ng/compile.js index ce3d0514e7bb..9687959b9f35 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -1369,11 +1369,9 @@ function $CompileProvider($provide) { function nodeLinkFn(childLinkFn, scope, linkNode, $rootElement, boundTranscludeFn) { var attrs, $element, i, ii, linkFn, controller, isolateScope, elementControllers = {}, transcludeFn; - if (compileNode === linkNode) { - attrs = templateAttrs; - } else { - attrs = shallowCopy(templateAttrs, new Attributes(jqLite(linkNode), templateAttrs.$attr)); - } + attrs = (compileNode === linkNode) + ? templateAttrs + : shallowCopy(templateAttrs, new Attributes(jqLite(linkNode), templateAttrs.$attr)); $element = attrs.$$element; if (newIsolateScopeDirective) { From ac134f0667410b3a85da133f8bd8a030412ff6ad Mon Sep 17 00:00:00 2001 From: Wladimir Coka Date: Thu, 21 Nov 2013 16:34:50 -0500 Subject: [PATCH 2/5] refactor(dateFilter): improve readability on conditional assignment Use ternary operator instead of if statement --- src/ng/filter/filters.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/ng/filter/filters.js b/src/ng/filter/filters.js index c92ed384792e..4163ca1c4a5c 100644 --- a/src/ng/filter/filters.js +++ b/src/ng/filter/filters.js @@ -382,11 +382,7 @@ function dateFilter($locale) { format = format || 'mediumDate'; format = $locale.DATETIME_FORMATS[format] || format; if (isString(date)) { - if (NUMBER_STRING.test(date)) { - date = int(date); - } else { - date = jsonStringToDate(date); - } + date = NUMBER_STRING.test(date) ? int(date) : jsonStringToDate(date); } if (isNumber(date)) { From e9775c6ad9e719fdfa3a0186349b7b8aeb19dfb4 Mon Sep 17 00:00:00 2001 From: Wladimir Coka Date: Thu, 21 Nov 2013 16:35:47 -0500 Subject: [PATCH 3/5] refactor($http): improve readability on conditional assignment Use ternary operator instead of if statement --- src/ng/http.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/ng/http.js b/src/ng/http.js index e7bbb8bc6e93..ec8169aebbdf 100644 --- a/src/ng/http.js +++ b/src/ng/http.js @@ -17,11 +17,7 @@ function parseHeaders(headers) { val = trim(line.substr(i + 1)); if (key) { - if (parsed[key]) { - parsed[key] += ', ' + val; - } else { - parsed[key] = val; - } + parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val; } }); From aa1d63478ade385832a913193a6e90f2fa8f7589 Mon Sep 17 00:00:00 2001 From: Wladimir Coka Date: Thu, 21 Nov 2013 16:37:35 -0500 Subject: [PATCH 4/5] refactor($parse): improve readability on conditional assignment Use logical OR operator instead of if statement --- src/ng/parse.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/ng/parse.js b/src/ng/parse.js index c93d07de1860..1432ff553e33 100644 --- a/src/ng/parse.js +++ b/src/ng/parse.js @@ -354,11 +354,7 @@ Lexer.prototype = { string += String.fromCharCode(parseInt(hex, 16)); } else { var rep = ESCAPE[ch]; - if (rep) { - string += rep; - } else { - string += ch; - } + string = string + (rep || ch); } escape = false; } else if (ch === '\\') { From fc2a23a4cf887e96da8fe9d6eee595a74e3b240c Mon Sep 17 00:00:00 2001 From: Wladimir Coka Date: Thu, 21 Nov 2013 16:38:29 -0500 Subject: [PATCH 5/5] refactor(ngScenario): improve readability on conditional assignment Use logical OR operator instead of if statement --- src/ngScenario/Scenario.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/ngScenario/Scenario.js b/src/ngScenario/Scenario.js index 9a30d8a9ace9..f0c3e3ebd0a1 100644 --- a/src/ngScenario/Scenario.js +++ b/src/ngScenario/Scenario.js @@ -313,11 +313,7 @@ _jQuery.fn.bindings = function(windowJquery, bindExp) { } for(var fns, j=0, jj=binding.length; j