From b46531977dd5c28b9e4c82d722f2bab8b3b05846 Mon Sep 17 00:00:00 2001 From: KaranChadha10 Date: Tue, 8 Apr 2025 01:45:52 +0530 Subject: [PATCH] refactor: removed unused braces for single line code --- .../Html/CodeFormatter/CodeFormat.cs | 10 -- .../Html/CodeFormatter/HtmlFormat.cs | 15 -- .../Html/CodeFormatter/SourceFormat.cs | 4 - .../Views/Admin/Configure.cshtml | 12 +- .../Views/_FixedRate.cshtml | 2 - .../ApplicationPartManagerExtensions.cs | 2 - .../Admin/Views/EmailAccount/Edit.cshtml | 2 - .../Admin/Views/EmailAccount/List.cshtml | 2 - .../Areas/Admin/Views/Payment/Methods.cshtml | 8 +- .../Areas/Admin/Views/Product/Create.cshtml | 4 - .../Setting/_GeneralCommon.Common.cshtml | 11 +- .../Admin/Views/Shipping/Providers.cshtml | 2 - .../Areas/Admin/Views/Tax/Providers.cshtml | 7 +- .../Areas/Admin/Views/Topic/Edit.cshtml | 2 - .../Areas/Admin/Views/Topic/List.cshtml | 2 - .../lib_npm/globalize/globalize/message.js | 152 ++++++++---------- 16 files changed, 80 insertions(+), 157 deletions(-) diff --git a/src/Libraries/Nop.Services/Html/CodeFormatter/CodeFormat.cs b/src/Libraries/Nop.Services/Html/CodeFormatter/CodeFormat.cs index b1e20d566c7..70ba2af0e5a 100644 --- a/src/Libraries/Nop.Services/Html/CodeFormatter/CodeFormat.cs +++ b/src/Libraries/Nop.Services/Html/CodeFormatter/CodeFormat.cs @@ -92,9 +92,7 @@ protected CodeFormat() regPreproc = r.Replace(regPreproc, @"|"); if (regPreproc.Length == 0) - { regPreproc = "(?!.*)_{37}(? 0) - { sb.Append('\n'); - } sb.Append(""); sb.Append(line); @@ -145,19 +141,13 @@ protected override string MatchEval(Match match) } if (match.Groups[2].Success) //string literal - { return "" + match + ""; - } if (match.Groups[3].Success) //preprocessor keyword - { return "" + match + ""; - } if (match.Groups[4].Success) //keyword - { return "" + match + ""; - } return string.Empty; //none of the above } diff --git a/src/Libraries/Nop.Services/Html/CodeFormatter/HtmlFormat.cs b/src/Libraries/Nop.Services/Html/CodeFormatter/HtmlFormat.cs index c7072192cea..72e6c8be58e 100644 --- a/src/Libraries/Nop.Services/Html/CodeFormatter/HtmlFormat.cs +++ b/src/Libraries/Nop.Services/Html/CodeFormatter/HtmlFormat.cs @@ -95,10 +95,7 @@ protected string AttributeMatchEval(Match match) protected override string MatchEval(Match match) { if (match.Groups[1].Success) //JavaScript code - { - //string s = match.ToString(); return _jsf.FormatSubCode(match.ToString()); - } if (match.Groups[2].Success) //comment { @@ -121,34 +118,22 @@ protected override string MatchEval(Match match) } if (match.Groups[3].Success) //asp tag - { return "" + match + ""; - } if (match.Groups[4].Success) //asp C# code - { return _csf.FormatSubCode(match.ToString()); - } if (match.Groups[5].Success) //tag delimiter - { return "" + match + ""; - } if (match.Groups[6].Success) //html tagname - { return "" + match + ""; - } if (match.Groups[7].Success) //attributes - { return _attributeRegex.Replace(match.ToString(), AttributeMatchEval); - } if (match.Groups[8].Success) //entity - { return "" + match + ""; - } return match.ToString(); } diff --git a/src/Libraries/Nop.Services/Html/CodeFormatter/SourceFormat.cs b/src/Libraries/Nop.Services/Html/CodeFormatter/SourceFormat.cs index 45033af01fe..8d70e9374a4 100644 --- a/src/Libraries/Nop.Services/Html/CodeFormatter/SourceFormat.cs +++ b/src/Libraries/Nop.Services/Html/CodeFormatter/SourceFormat.cs @@ -190,13 +190,9 @@ protected string FormatCode(string source, bool lineNumbers, { i++; if (alternate && i % 2 == 1) - { sb.Append("
");
-                }
                 else
-                {
                     sb.Append("
");
-                }
 
                 if (lineNumbers)
                 {
diff --git a/src/Plugins/Nop.Plugin.Payments.PayPalCommerce/Views/Admin/Configure.cshtml b/src/Plugins/Nop.Plugin.Payments.PayPalCommerce/Views/Admin/Configure.cshtml
index f51f0522c34..cd7efc7177a 100644
--- a/src/Plugins/Nop.Plugin.Payments.PayPalCommerce/Views/Admin/Configure.cshtml
+++ b/src/Plugins/Nop.Plugin.Payments.PayPalCommerce/Views/Admin/Configure.cshtml
@@ -10,18 +10,16 @@
 @await Component.InvokeAsync(typeof(StoreScopeConfigurationViewComponent))
 
 @if (Model.IsConfigured)
-{
     @await Component.InvokeAsync(typeof(SettingModeViewComponent))
-}
 
 
 
 @if (await Html.IsTourActiveAsync())
-{
     @await Html.PartialAsync("_List.Tour")
-}
\ No newline at end of file
diff --git a/src/Presentation/Nop.Web/Areas/Admin/Views/Payment/Methods.cshtml b/src/Presentation/Nop.Web/Areas/Admin/Views/Payment/Methods.cshtml
index afb2b5d2710..a03b398aecd 100644
--- a/src/Presentation/Nop.Web/Areas/Admin/Views/Payment/Methods.cshtml
+++ b/src/Presentation/Nop.Web/Areas/Admin/Views/Payment/Methods.cshtml
@@ -118,11 +118,11 @@
                         
                         
                     
@@ -134,6 +134,4 @@
 
 
 @if (await Html.IsTourActiveAsync())
-{
     @await Html.PartialAsync("_Methods.Tour")
-}
\ No newline at end of file
diff --git a/src/Presentation/Nop.Web/Areas/Admin/Views/Product/Create.cshtml b/src/Presentation/Nop.Web/Areas/Admin/Views/Product/Create.cshtml
index 3114ee47b83..68afbad8075 100644
--- a/src/Presentation/Nop.Web/Areas/Admin/Views/Product/Create.cshtml
+++ b/src/Presentation/Nop.Web/Areas/Admin/Views/Product/Create.cshtml
@@ -33,12 +33,8 @@
     @await Html.PartialAsync("_CreateOrUpdate", Model)
 
 @if (!Model.IsLoggedInAsVendor)
-{
     //product editor settings modal
     @await Html.PartialAsync("_ProductEditorSettingsModal", Model)
-}
 
 @if (await Html.IsTourActiveAsync())
-{
     @await Html.PartialAsync("_Create.Tour")
-}
\ No newline at end of file
diff --git a/src/Presentation/Nop.Web/Areas/Admin/Views/Setting/_GeneralCommon.Common.cshtml b/src/Presentation/Nop.Web/Areas/Admin/Views/Setting/_GeneralCommon.Common.cshtml
index 44daf4b6505..ebeb5569741 100644
--- a/src/Presentation/Nop.Web/Areas/Admin/Views/Setting/_GeneralCommon.Common.cshtml
+++ b/src/Presentation/Nop.Web/Areas/Admin/Views/Setting/_GeneralCommon.Common.cshtml
@@ -22,9 +22,12 @@
                     
@@ -107,6 +110,4 @@ @if (await Html.IsTourActiveAsync()) -{ @await Html.PartialAsync("_GeneralCommon.Common.Tour") -} \ No newline at end of file diff --git a/src/Presentation/Nop.Web/Areas/Admin/Views/Shipping/Providers.cshtml b/src/Presentation/Nop.Web/Areas/Admin/Views/Shipping/Providers.cshtml index 5f73a3c0374..90e9e64de0f 100644 --- a/src/Presentation/Nop.Web/Areas/Admin/Views/Shipping/Providers.cshtml +++ b/src/Presentation/Nop.Web/Areas/Admin/Views/Shipping/Providers.cshtml @@ -101,6 +101,4 @@ @if (await Html.IsTourActiveAsync()) -{ @await Html.PartialAsync("_Providers.Tour") -} diff --git a/src/Presentation/Nop.Web/Areas/Admin/Views/Tax/Providers.cshtml b/src/Presentation/Nop.Web/Areas/Admin/Views/Tax/Providers.cshtml index b1e07290c54..feaf3f209f0 100644 --- a/src/Presentation/Nop.Web/Areas/Admin/Views/Tax/Providers.cshtml +++ b/src/Presentation/Nop.Web/Areas/Admin/Views/Tax/Providers.cshtml @@ -79,11 +79,10 @@ } function renderColumnConfigure(data, type, row, meta) { - if (row.ConfigurationUrl && row.ConfigurationUrl.length > 0) { + if (row.ConfigurationUrl && row.ConfigurationUrl.length > 0) return '@T("Admin.Configuration.Tax.Providers.Configure").Text'; - } else { + else return ''; - } } @@ -95,6 +94,4 @@ @if (await Html.IsTourActiveAsync()) -{ @await Html.PartialAsync("_Providers.Tour") -} \ No newline at end of file diff --git a/src/Presentation/Nop.Web/Areas/Admin/Views/Topic/Edit.cshtml b/src/Presentation/Nop.Web/Areas/Admin/Views/Topic/Edit.cshtml index 4f67ae2aa8c..e48a4c2c303 100644 --- a/src/Presentation/Nop.Web/Areas/Admin/Views/Topic/Edit.cshtml +++ b/src/Presentation/Nop.Web/Areas/Admin/Views/Topic/Edit.cshtml @@ -42,6 +42,4 @@ @if (await Html.IsTourActiveAsync()) -{ @await Html.PartialAsync("_Edit.Tour") -} diff --git a/src/Presentation/Nop.Web/Areas/Admin/Views/Topic/List.cshtml b/src/Presentation/Nop.Web/Areas/Admin/Views/Topic/List.cshtml index 2036af2d05c..ce1624f68d8 100644 --- a/src/Presentation/Nop.Web/Areas/Admin/Views/Topic/List.cshtml +++ b/src/Presentation/Nop.Web/Areas/Admin/Views/Topic/List.cshtml @@ -174,6 +174,4 @@ @if (await Html.IsTourActiveAsync()) -{ @await Html.PartialAsync("_List.Tour") -} \ No newline at end of file diff --git a/src/Presentation/Nop.Web/wwwroot/lib_npm/globalize/globalize/message.js b/src/Presentation/Nop.Web/wwwroot/lib_npm/globalize/globalize/message.js index ec875eae5bd..9286abfdf8e 100644 --- a/src/Presentation/Nop.Web/wwwroot/lib_npm/globalize/globalize/message.js +++ b/src/Presentation/Nop.Web/wwwroot/lib_npm/globalize/globalize/message.js @@ -16,7 +16,7 @@ (function( root, factory ) { // UMD returnExports - if ( typeof define === "function" && define.amd ) { + if ( typeof define === "function" && define.amd ) // AMD define([ @@ -24,15 +24,15 @@ "../globalize", "cldr/event" ], factory ); - } else if ( typeof exports === "object" ) { + else if ( typeof exports === "object" ) // Node, CommonJS module.exports = factory( require( "cldrjs" ), require( "../globalize" ) ); - } else { + else // Extend global factory( root.Cldr, root.Globalize ); - } + }(this, function( Cldr, Globalize ) { var alwaysArray = Globalize._alwaysArray, @@ -190,9 +190,9 @@ MessageFormat._parse = (function() { peg$result; if ("startRule" in options) { - if (!(options.startRule in peg$startRuleFunctions)) { + if (!(options.startRule in peg$startRuleFunctions)) throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); - } + peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; } @@ -232,7 +232,7 @@ MessageFormat._parse = (function() { for (p = startPos; p < endPos; p++) { ch = input.charAt(p); if (ch === "\n") { - if (!details.seenCR) { details.line++; } + if (!details.seenCR) details.line++; details.column = 1; details.seenCR = false; } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") { @@ -259,7 +259,7 @@ MessageFormat._parse = (function() { } function peg$fail(expected) { - if (peg$currPos < peg$maxFailPos) { return; } + if (peg$currPos < peg$maxFailPos) return; if (peg$currPos > peg$maxFailPos) { peg$maxFailPos = peg$currPos; @@ -274,21 +274,21 @@ MessageFormat._parse = (function() { var i = 1; expected.sort(function(a, b) { - if (a.description < b.description) { + if (a.description < b.description) return -1; - } else if (a.description > b.description) { + else if (a.description > b.description) return 1; - } else { + else return 0; - } + }); while (i < expected.length) { - if (expected[i - 1] === expected[i]) { + if (expected[i - 1] === expected[i]) expected.splice(i, 1); - } else { + else i++; - } + } } @@ -313,9 +313,9 @@ MessageFormat._parse = (function() { var expectedDescs = new Array(expected.length), expectedDesc, foundDesc, i; - for (i = 0; i < expected.length; i++) { + for (i = 0; i < expected.length; i++) expectedDescs[i] = expected[i].description; - } + expectedDesc = expected.length > 1 ? expectedDescs.slice(0, -1).join(", ") @@ -331,9 +331,9 @@ MessageFormat._parse = (function() { var posDetails = peg$computePosDetails(pos), found = pos < input.length ? input.charAt(pos) : null; - if (expected !== null) { + if (expected !== null) cleanupExpected(expected); - } + return new SyntaxError( message !== null ? message : buildMessage(expected, found), @@ -361,18 +361,16 @@ MessageFormat._parse = (function() { s2 = peg$parsemessageFormatElement(); if (s2 === peg$FAILED) { s2 = peg$parsestring(); - if (s2 === peg$FAILED) { + if (s2 === peg$FAILED) s2 = peg$parseoctothorpe(); - } } while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parsemessageFormatElement(); if (s2 === peg$FAILED) { s2 = peg$parsestring(); - if (s2 === peg$FAILED) { + if (s2 === peg$FAILED) s2 = peg$parseoctothorpe(); - } } } if (s1 !== peg$FAILED) { @@ -421,9 +419,7 @@ MessageFormat._parse = (function() { peg$currPos = s4; s4 = peg$c2; } - if (s4 === peg$FAILED) { - s4 = peg$c5; - } + if (s4 === peg$FAILED) s4 = peg$c5; if (s4 !== peg$FAILED) { s5 = peg$parse_(); if (s5 !== peg$FAILED) { @@ -477,7 +473,7 @@ MessageFormat._parse = (function() { peg$currPos += 6; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c12); } + if (peg$silentFails === 0) peg$fail(peg$c12); } if (s2 !== peg$FAILED) { s3 = peg$parse_(); @@ -536,7 +532,7 @@ MessageFormat._parse = (function() { peg$currPos += 13; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c15); } + if (peg$silentFails === 0) peg$fail(peg$c15); } if (s2 !== peg$FAILED) { s3 = peg$parse_(); @@ -546,7 +542,7 @@ MessageFormat._parse = (function() { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c7); } + if (peg$silentFails === 0) peg$fail(peg$c7); } if (s4 !== peg$FAILED) { s5 = peg$parse_(); @@ -595,7 +591,7 @@ MessageFormat._parse = (function() { peg$currPos += 6; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c17); } + if (peg$silentFails === 0) peg$fail(peg$c17); } if (s2 !== peg$FAILED) { s3 = peg$parse_(); @@ -605,7 +601,7 @@ MessageFormat._parse = (function() { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c7); } + if (peg$silentFails === 0) peg$fail(peg$c7); } if (s4 !== peg$FAILED) { s5 = peg$parse_(); @@ -726,7 +722,7 @@ MessageFormat._parse = (function() { peg$currPos += 6; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c21); } + if (peg$silentFails === 0) peg$fail(peg$c21); } if (s2 !== peg$FAILED) { s3 = peg$parse_(); @@ -736,7 +732,7 @@ MessageFormat._parse = (function() { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c23); } + if (peg$silentFails === 0) peg$fail(peg$c23); } if (s4 !== peg$FAILED) { s5 = peg$parse_(); @@ -795,7 +791,7 @@ MessageFormat._parse = (function() { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c4); } + if (peg$silentFails === 0) peg$fail(peg$c4); } if (s4 !== peg$FAILED) { s5 = peg$parse_(); @@ -809,7 +805,7 @@ MessageFormat._parse = (function() { peg$currPos++; } else { s8 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c9); } + if (peg$silentFails === 0) peg$fail(peg$c9); } if (s8 !== peg$FAILED) { peg$reportedPos = s0; @@ -868,7 +864,7 @@ MessageFormat._parse = (function() { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c28); } + if (peg$silentFails === 0) peg$fail(peg$c28); } if (s1 !== peg$FAILED) { s2 = peg$parsedigits(); @@ -927,7 +923,7 @@ MessageFormat._parse = (function() { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c4); } + if (peg$silentFails === 0) peg$fail(peg$c4); } if (s4 !== peg$FAILED) { s5 = peg$parse_(); @@ -941,7 +937,7 @@ MessageFormat._parse = (function() { peg$currPos++; } else { s8 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c9); } + if (peg$silentFails === 0) peg$fail(peg$c9); } if (s8 !== peg$FAILED) { peg$reportedPos = s0; @@ -994,7 +990,7 @@ MessageFormat._parse = (function() { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c7); } + if (peg$silentFails === 0) peg$fail(peg$c7); } if (s2 !== peg$FAILED) { s3 = peg$parse_(); @@ -1039,7 +1035,7 @@ MessageFormat._parse = (function() { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c32); } + if (peg$silentFails === 0) peg$fail(peg$c32); } if (s1 !== peg$FAILED) { peg$reportedPos = s0; @@ -1056,16 +1052,12 @@ MessageFormat._parse = (function() { s0 = peg$currPos; s1 = []; s2 = peg$parsechars(); - if (s2 === peg$FAILED) { - s2 = peg$parsewhitespace(); - } + if (s2 === peg$FAILED) s2 = peg$parsewhitespace(); if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { s1.push(s2); s2 = peg$parsechars(); - if (s2 === peg$FAILED) { - s2 = peg$parsewhitespace(); - } + if (s2 === peg$FAILED) s2 = peg$parsewhitespace(); } } else { s1 = peg$c2; @@ -1093,7 +1085,7 @@ MessageFormat._parse = (function() { peg$currPos++; } else { s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c37); } + if (peg$silentFails === 0) peg$fail(peg$c37); } if (s4 !== peg$FAILED) { s5 = []; @@ -1102,7 +1094,7 @@ MessageFormat._parse = (function() { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c39); } + if (peg$silentFails === 0) peg$fail(peg$c39); } while (s6 !== peg$FAILED) { s5.push(s6); @@ -1111,7 +1103,7 @@ MessageFormat._parse = (function() { peg$currPos++; } else { s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c39); } + if (peg$silentFails === 0) peg$fail(peg$c39); } } if (s5 !== peg$FAILED) { @@ -1125,9 +1117,7 @@ MessageFormat._parse = (function() { peg$currPos = s3; s3 = peg$c2; } - if (s3 !== peg$FAILED) { - s3 = input.substring(s2, peg$currPos); - } + if (s3 !== peg$FAILED) s3 = input.substring(s2, peg$currPos); s2 = s3; if (s2 !== peg$FAILED) { s3 = peg$parse_(); @@ -1150,7 +1140,7 @@ MessageFormat._parse = (function() { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c35); } + if (peg$silentFails === 0) peg$fail(peg$c35); } return s0; @@ -1188,7 +1178,7 @@ MessageFormat._parse = (function() { peg$currPos++; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c43); } + if (peg$silentFails === 0) peg$fail(peg$c43); } if (s1 !== peg$FAILED) { peg$reportedPos = s0; @@ -1202,7 +1192,7 @@ MessageFormat._parse = (function() { peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c46); } + if (peg$silentFails === 0) peg$fail(peg$c46); } if (s1 !== peg$FAILED) { peg$reportedPos = s0; @@ -1216,7 +1206,7 @@ MessageFormat._parse = (function() { peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c49); } + if (peg$silentFails === 0) peg$fail(peg$c49); } if (s1 !== peg$FAILED) { peg$reportedPos = s0; @@ -1230,7 +1220,7 @@ MessageFormat._parse = (function() { peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c52); } + if (peg$silentFails === 0) peg$fail(peg$c52); } if (s1 !== peg$FAILED) { peg$reportedPos = s0; @@ -1244,7 +1234,7 @@ MessageFormat._parse = (function() { peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c55); } + if (peg$silentFails === 0) peg$fail(peg$c55); } if (s1 !== peg$FAILED) { peg$reportedPos = s0; @@ -1258,7 +1248,7 @@ MessageFormat._parse = (function() { peg$currPos += 2; } else { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c58); } + if (peg$silentFails === 0) peg$fail(peg$c58); } if (s1 !== peg$FAILED) { s2 = peg$parsehexDigit(); @@ -1311,7 +1301,7 @@ MessageFormat._parse = (function() { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c61); } + if (peg$silentFails === 0) peg$fail(peg$c61); } if (s2 !== peg$FAILED) { while (s2 !== peg$FAILED) { @@ -1321,7 +1311,7 @@ MessageFormat._parse = (function() { peg$currPos++; } else { s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c61); } + if (peg$silentFails === 0) peg$fail(peg$c61); } } } else { @@ -1344,7 +1334,7 @@ MessageFormat._parse = (function() { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c64); } + if (peg$silentFails === 0) peg$fail(peg$c64); } return s0; @@ -1369,7 +1359,7 @@ MessageFormat._parse = (function() { peg$silentFails--; if (s0 === peg$FAILED) { s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c65); } + if (peg$silentFails === 0) peg$fail(peg$c65); } return s0; @@ -1383,7 +1373,7 @@ MessageFormat._parse = (function() { peg$currPos++; } else { s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$c68); } + if (peg$silentFails === 0) peg$fail(peg$c68); } return s0; @@ -1419,9 +1409,9 @@ MessageFormat._parse = (function() { /** Utility function for quoting an Object's key value iff required * @private */ function propname(key, obj) { - if (/^[A-Z_$][0-9A-Z_$]*$/i.test(key)) { + if (/^[A-Z_$][0-9A-Z_$]*$/i.test(key)) return obj ? obj + '.' + key : key; - } else { + else { var jkey = JSON.stringify(key); return obj ? obj + '[' + jkey + ']' : jkey; } @@ -1440,9 +1430,8 @@ function MessageFormat(locale, pluralFunc, formatters) { this.runtime.pluralFuncs = {}; this.runtime.pluralFuncs[this.lc[0]] = pluralFunc; this.runtime.fmt = {}; - if (formatters) for (var f in formatters) { + if (formatters) for (var f in formatters) this.runtime.fmt[f] = formatters[f]; - } } @@ -1624,9 +1613,8 @@ MessageFormat.prototype._precompile = function(ast, data) { case 'messageFormatElement': data.pf_count = data.pf_count || 0; - if ( ast.output ) { + if ( ast.output ) return propname(ast.argumentIndex, 'd'); - } else { data.keys[data.pf_count] = ast.argumentIndex; return this._precompile( ast.elementFormat, data ); @@ -1944,17 +1932,11 @@ var messageFormatterRuntimeBind = function( cldr, messageformatter ) { // Properly adjust SlexAxton/messageformat.js compiled variables with Globalize variables: output = origToString.call( messageformatter ); - if ( /number\(/.test( output ) ) { - args.number = "messageFormat.number"; - } + if ( /number\(/.test( output ) ) args.number = "messageFormat.number"; - if ( /plural\(/.test( output ) ) { - args.plural = "messageFormat.plural"; - } + if ( /plural\(/.test( output ) ) args.plural = "messageFormat.plural"; - if ( /select\(/.test( output ) ) { - args.select = "messageFormat.select"; - } + if ( /select\(/.test( output ) ) args.select = "messageFormat.select"; output.replace( /pluralFuncs(\[([^\]]+)\]|\.([a-zA-Z]+))/, function( match ) { args.pluralFuncs = "{" + @@ -1976,9 +1958,6 @@ var messageFormatterRuntimeBind = function( cldr, messageformatter ) { return messageformatter; }; - - - var slice = [].slice; /** @@ -2000,9 +1979,8 @@ Globalize.loadMessages = function( json ) { // Set available bundles by populating customData main dataset. for ( locale in json ) { - if ( json.hasOwnProperty( locale ) ) { + if ( json.hasOwnProperty( locale ) ) customData.main[ locale ] = {}; - } } Cldr.load( customData ); @@ -2034,9 +2012,9 @@ Globalize.prototype.messageFormatter = function( path ) { validateMessagePresence( path, message ); // If message is an Array, concatenate it. - if ( Array.isArray( message ) ) { - message = message.join( " " ); - } + if ( Array.isArray( message ) ) + message = message.join(" "); + validateMessageType( path, message ); // Is plural module present? Yes, use its generator. Nope, use an error generator.