diff --git a/closure/goog/color/alpha.js b/closure/goog/color/alpha.js index 5fd1bd63d9..0e931006ff 100644 --- a/closure/goog/color/alpha.js +++ b/closure/goog/color/alpha.js @@ -22,6 +22,7 @@ goog.require('goog.color'); * containing the type of color format passed in ('hex', 'rgb', 'named'). */ goog.color.alpha.parse = function(str) { + 'use strict'; var result = {}; str = String(str); @@ -56,6 +57,7 @@ goog.color.alpha.parse = function(str) { * styles. */ goog.color.alpha.hexToRgbaStyle = function(hexColor) { + 'use strict'; return goog.color.alpha.rgbaStyle_(goog.color.alpha.hexToRgba(hexColor)); }; @@ -71,6 +73,7 @@ goog.color.alpha.hexToRgbaStyle = function(hexColor) { * @private */ goog.color.alpha.extractColor_ = function(colorWithAlpha, startIdx, endIdx) { + 'use strict'; if (goog.color.alpha.isValidAlphaHexColor_(colorWithAlpha)) { var fullColor = goog.color.prependHashIfNecessaryHelper(colorWithAlpha); var normalizedColor = goog.color.alpha.normalizeAlphaHex_(fullColor); @@ -88,6 +91,7 @@ goog.color.alpha.extractColor_ = function(colorWithAlpha, startIdx, endIdx) { * @return {string} The hex color where the alpha part has been stripped off. */ goog.color.alpha.extractHexColor = function(colorWithAlpha) { + 'use strict'; return goog.color.alpha.extractColor_(colorWithAlpha, 0, 7); }; @@ -99,6 +103,7 @@ goog.color.alpha.extractHexColor = function(colorWithAlpha) { * @return {string} The two-character alpha from the given color. */ goog.color.alpha.extractAlpha = function(colorWithAlpha) { + 'use strict'; return goog.color.alpha.extractColor_(colorWithAlpha, 7, 9); }; @@ -119,6 +124,7 @@ goog.color.alpha.hexQuadrupletRe_ = /#(.)(.)(.)(.)/; * @private */ goog.color.alpha.normalizeAlphaHex_ = function(hexColor) { + 'use strict'; if (!goog.color.alpha.isValidAlphaHexColor_(hexColor)) { throw new Error('\'' + hexColor + '\' is not a valid alpha hex color'); } @@ -138,6 +144,7 @@ goog.color.alpha.normalizeAlphaHex_ = function(hexColor) { * and 255, and a is a value between 0 and 1. */ goog.color.alpha.hexToRgba = function(hexColor) { + 'use strict'; // TODO(user): Enhance code sharing with goog.color, for example by // adding a goog.color.genericHexToRgb method. hexColor = goog.color.alpha.normalizeAlphaHex_(hexColor); @@ -159,6 +166,7 @@ goog.color.alpha.hexToRgba = function(hexColor) { * @return {string} hex representation of the color. */ goog.color.alpha.rgbaToHex = function(r, g, b, a) { + 'use strict'; var intAlpha = Math.floor(a * 255); if (isNaN(intAlpha) || intAlpha < 0 || intAlpha > 255) { // TODO(user): The CSS spec says the value should be clamped. @@ -180,6 +188,7 @@ goog.color.alpha.rgbaToHex = function(r, g, b, a) { * @return {string} hex representation of the color. */ goog.color.alpha.hslaToHex = function(h, s, l, a) { + 'use strict'; var intAlpha = Math.floor(a * 255); if (isNaN(intAlpha) || intAlpha < 0 || intAlpha > 255) { // TODO(user): The CSS spec says the value should be clamped. @@ -199,6 +208,7 @@ goog.color.alpha.hslaToHex = function(h, s, l, a) { * @return {string} hex representation of the color. */ goog.color.alpha.rgbaArrayToHex = function(rgba) { + 'use strict'; return goog.color.alpha.rgbaToHex(rgba[0], rgba[1], rgba[2], rgba[3]); }; @@ -212,6 +222,7 @@ goog.color.alpha.rgbaArrayToHex = function(rgba) { * @return {string} An 'rgba(r,g,b,a)' string ready for use in a CSS rule. */ goog.color.alpha.rgbaToRgbaStyle = function(r, g, b, a) { + 'use strict'; if (isNaN(r) || r < 0 || r > 255 || isNaN(g) || g < 0 || g > 255 || isNaN(b) || b < 0 || b > 255 || isNaN(a) || a < 0 || a > 1) { throw new Error( @@ -229,6 +240,7 @@ goog.color.alpha.rgbaToRgbaStyle = function(r, g, b, a) { * @return {string} An 'rgba(r,g,b,a)' string ready for use in a CSS rule. */ goog.color.alpha.rgbaArrayToRgbaStyle = function(rgba) { + 'use strict'; return goog.color.alpha.rgbaToRgbaStyle(rgba[0], rgba[1], rgba[2], rgba[3]); }; @@ -240,6 +252,7 @@ goog.color.alpha.rgbaArrayToRgbaStyle = function(rgba) { * @return {string} hex representation of the color, such as '#af457eff'. */ goog.color.alpha.hslaArrayToHex = function(hsla) { + 'use strict'; return goog.color.alpha.hslaToHex(hsla[0], hsla[1], hsla[2], hsla[3]); }; @@ -251,6 +264,7 @@ goog.color.alpha.hslaArrayToHex = function(hsla) { * @return {string} An 'rgba(r,g,b,a)' string ready for use in a CSS rule. */ goog.color.alpha.hslaArrayToRgbaStyle = function(hsla) { + 'use strict'; return goog.color.alpha.hslaToRgbaStyle(hsla[0], hsla[1], hsla[2], hsla[3]); }; @@ -265,6 +279,7 @@ goog.color.alpha.hslaArrayToRgbaStyle = function(hsla) { * styles. */ goog.color.alpha.hslaToRgbaStyle = function(h, s, l, a) { + 'use strict'; return goog.color.alpha.rgbaStyle_(goog.color.alpha.hslaToRgba(h, s, l, a)); }; @@ -279,6 +294,7 @@ goog.color.alpha.hslaToRgbaStyle = function(h, s, l, a) { * are integers in [0, 255] and a is a float in [0, 1]. */ goog.color.alpha.hslaToRgba = function(h, s, l, a) { + 'use strict'; return goog.color.hslToRgb(h, s / 100, l / 100).concat(a); }; @@ -294,6 +310,7 @@ goog.color.alpha.hslaToRgba = function(h, s, l, a) { * [0, 360] and s, l and a in [0, 1]. */ goog.color.alpha.rgbaToHsla = function(r, g, b, a) { + 'use strict'; return goog.color.rgbToHsl(r, g, b).concat(a); }; @@ -306,6 +323,7 @@ goog.color.alpha.rgbaToHsla = function(r, g, b, a) { * [0, 360] and s, l and a in [0, 1]. */ goog.color.alpha.rgbaArrayToHsla = function(rgba) { + 'use strict'; return goog.color.alpha.rgbaToHsla(rgba[0], rgba[1], rgba[2], rgba[3]); }; @@ -327,6 +345,7 @@ goog.color.alpha.validAlphaHexColorRe_ = /^#(?:[0-9a-f]{4}){1,2}$/i; */ // TODO(user): Support percentages when goog.color also supports them. goog.color.alpha.isValidAlphaHexColor_ = function(str) { + 'use strict'; return goog.color.alpha.validAlphaHexColorRe_.test(str); }; @@ -348,6 +367,7 @@ goog.color.alpha.normalizedAlphaHexColorRe_ = /^#[0-9a-f]{8}$/; * @private */ goog.color.alpha.isNormalizedAlphaHexColor_ = function(str) { + 'use strict'; return goog.color.alpha.normalizedAlphaHexColorRe_.test(str); }; @@ -405,6 +425,7 @@ goog.color.alpha.hslaColorRe_ = new RegExp( * @private */ goog.color.alpha.isValidRgbaColor_ = function(str) { + 'use strict'; // Each component is separate (rather than using a repeater) so we can // capture the match. Also, we explicitly set each component to be either 0, // or start with a non-zero, to prevent octal numbers from slipping through. @@ -433,6 +454,7 @@ goog.color.alpha.isValidRgbaColor_ = function(str) { * @private */ goog.color.alpha.isValidHslaColor_ = function(str) { + 'use strict'; // Each component is separate (rather than using a repeater) so we can // capture the match. Also, we explicitly set each component to be either 0, // or start with a non-zero, to prevent octal numbers from slipping through. @@ -461,6 +483,7 @@ goog.color.alpha.isValidHslaColor_ = function(str) { * @private */ goog.color.alpha.rgbaStyle_ = function(rgba) { + 'use strict'; var roundedRgba = rgba.slice(0); roundedRgba[3] = Math.round(rgba[3] * 1000) / 1000; return 'rgba(' + roundedRgba.join(',') + ')'; @@ -476,6 +499,7 @@ goog.color.alpha.rgbaStyle_ = function(rgba) { * @return {string} hex representation of the color. */ goog.color.alpha.hsvaToHex = function(h, s, v, a) { + 'use strict'; var alpha = Math.floor(a * 255); return goog.color.hsvArrayToHex([h, s, v]) + goog.color.prependZeroIfNecessaryHelper(alpha.toString(16)); @@ -489,5 +513,6 @@ goog.color.alpha.hsvaToHex = function(h, s, v, a) { * @return {string} hex representation of the color. */ goog.color.alpha.hsvaArrayToHex = function(hsva) { + 'use strict'; return goog.color.alpha.hsvaToHex(hsva[0], hsva[1], hsva[2], hsva[3]); }; diff --git a/closure/goog/color/color.js b/closure/goog/color/color.js index 06777a3de6..7abb846f28 100644 --- a/closure/goog/color/color.js +++ b/closure/goog/color/color.js @@ -54,6 +54,7 @@ goog.color.Hsl; * of color format passed in ('hex', 'rgb', 'named'). */ goog.color.parse = function(str) { + 'use strict'; var result = {}; str = String(str); @@ -88,6 +89,7 @@ goog.color.parse = function(str) { * @return {boolean} True if str is in a format that can be parsed to a color. */ goog.color.isValidColor = function(str) { + 'use strict'; var maybeHex = goog.color.prependHashIfNecessaryHelper(str); return !!( goog.color.isValidHexColor_(maybeHex) || @@ -104,6 +106,7 @@ goog.color.isValidColor = function(str) { * @return {!goog.color.Rgb} rgb representation of the color. */ goog.color.parseRgb = function(str) { + 'use strict'; var rgb = goog.color.isValidRgbColor_(str); if (!rgb.length) { throw Error(str + ' is not a valid RGB color'); @@ -119,6 +122,7 @@ goog.color.parseRgb = function(str) { * styles. */ goog.color.hexToRgbStyle = function(hexColor) { + 'use strict'; return goog.color.rgbStyle_(goog.color.hexToRgb(hexColor)); }; @@ -138,6 +142,7 @@ goog.color.hexTripletRe_ = /#(.)(.)(.)/; * literals. */ goog.color.normalizeHex = function(hexColor) { + 'use strict'; if (!goog.color.isValidHexColor_(hexColor)) { throw Error("'" + hexColor + "' is not a valid hex color"); } @@ -154,6 +159,7 @@ goog.color.normalizeHex = function(hexColor) { * @return {!goog.color.Rgb} rgb representation of the color. */ goog.color.hexToRgb = function(hexColor) { + 'use strict'; hexColor = goog.color.normalizeHex(hexColor); var rgb = parseInt(hexColor.substr(1), 16); var r = rgb >> 16; @@ -172,6 +178,7 @@ goog.color.hexToRgb = function(hexColor) { * @return {string} hex representation of the color. */ goog.color.rgbToHex = function(r, g, b) { + 'use strict'; r = Number(r); g = Number(g); b = Number(b); @@ -192,6 +199,7 @@ goog.color.rgbToHex = function(r, g, b) { * @return {string} hex representation of the color. */ goog.color.rgbArrayToHex = function(rgb) { + 'use strict'; return goog.color.rgbToHex(rgb[0], rgb[1], rgb[2]); }; @@ -205,6 +213,7 @@ goog.color.rgbArrayToHex = function(rgb) { * @return {!goog.color.Hsl} hsl representation of the color. */ goog.color.rgbToHsl = function(r, g, b) { + 'use strict'; // First must normalize r, g, b to be between 0 and 1. var normR = r / 255; var normG = g / 255; @@ -246,6 +255,7 @@ goog.color.rgbToHsl = function(r, g, b) { * @return {!goog.color.Hsl} hsl representation of the color. */ goog.color.rgbArrayToHsl = function(rgb) { + 'use strict'; return goog.color.rgbToHsl(rgb[0], rgb[1], rgb[2]); }; @@ -259,6 +269,7 @@ goog.color.rgbArrayToHsl = function(rgb) { * @private */ goog.color.hueToRgb_ = function(v1, v2, vH) { + 'use strict'; if (vH < 0) { vH += 1; } else if (vH > 1) { @@ -284,6 +295,7 @@ goog.color.hueToRgb_ = function(v1, v2, vH) { * @return {!goog.color.Rgb} rgb representation of the color. */ goog.color.hslToRgb = function(h, s, l) { + 'use strict'; var r = 0; var g = 0; var b = 0; @@ -315,6 +327,7 @@ goog.color.hslToRgb = function(h, s, l) { * @return {!goog.color.Rgb} rgb representation of the color. */ goog.color.hslArrayToRgb = function(hsl) { + 'use strict'; return goog.color.hslToRgb(hsl[0], hsl[1], hsl[2]); }; @@ -335,6 +348,7 @@ goog.color.validHexColorRe_ = /^#(?:[0-9a-f]{3}){1,2}$/i; * @private */ goog.color.isValidHexColor_ = function(str) { + 'use strict'; return goog.color.validHexColorRe_.test(str); }; @@ -359,6 +373,7 @@ goog.color.rgbColorRe_ = * @private */ goog.color.isValidRgbColor_ = function(str) { + 'use strict'; // Each component is separate (rather than using a repeater) so we can // capture the match. Also, we explicitly set each component to be either 0, // or start with a non-zero, to prevent octal numbers from slipping through. @@ -383,6 +398,7 @@ goog.color.isValidRgbColor_ = function(str) { * otherwise the same value that was passed in. */ goog.color.prependZeroIfNecessaryHelper = function(hex) { + 'use strict'; return hex.length == 1 ? '0' + hex : hex; }; @@ -395,6 +411,7 @@ goog.color.prependZeroIfNecessaryHelper = function(hex) { * already have one. */ goog.color.prependHashIfNecessaryHelper = function(str) { + 'use strict'; return str.charAt(0) == '#' ? str : '#' + str; }; @@ -407,6 +424,7 @@ goog.color.prependHashIfNecessaryHelper = function(str) { * @private */ goog.color.rgbStyle_ = function(rgb) { + 'use strict'; return 'rgb(' + rgb.join(',') + ')'; }; @@ -420,6 +438,7 @@ goog.color.rgbStyle_ = function(rgb) { * @return {!goog.color.Rgb} rgb representation of the color. */ goog.color.hsvToRgb = function(h, s, brightness) { + 'use strict'; var red = 0; var green = 0; var blue = 0; @@ -480,7 +499,7 @@ goog.color.hsvToRgb = function(h, s, brightness) { * @return {!goog.color.Hsv} hsv representation of the color. */ goog.color.rgbToHsv = function(red, green, blue) { - + 'use strict'; var max = Math.max(Math.max(red, green), blue); var min = Math.min(Math.min(red, green), blue); var hue; @@ -519,6 +538,7 @@ goog.color.rgbToHsv = function(red, green, blue) { * @return {!goog.color.Hsv} hsv representation of the color. */ goog.color.rgbArrayToHsv = function(rgb) { + 'use strict'; return goog.color.rgbToHsv(rgb[0], rgb[1], rgb[2]); }; @@ -529,6 +549,7 @@ goog.color.rgbArrayToHsv = function(rgb) { * @return {!goog.color.Rgb} rgb representation of the color. */ goog.color.hsvArrayToRgb = function(hsv) { + 'use strict'; return goog.color.hsvToRgb(hsv[0], hsv[1], hsv[2]); }; @@ -539,6 +560,7 @@ goog.color.hsvArrayToRgb = function(hsv) { * @return {!goog.color.Hsl} hsl representation of the color. */ goog.color.hexToHsl = function(hex) { + 'use strict'; var rgb = goog.color.hexToRgb(hex); return goog.color.rgbToHsl(rgb[0], rgb[1], rgb[2]); }; @@ -552,6 +574,7 @@ goog.color.hexToHsl = function(hex) { * @return {string} hex representation of the color. */ goog.color.hslToHex = function(h, s, l) { + 'use strict'; return goog.color.rgbArrayToHex(goog.color.hslToRgb(h, s, l)); }; @@ -562,6 +585,7 @@ goog.color.hslToHex = function(h, s, l) { * @return {string} hex representation of the color. */ goog.color.hslArrayToHex = function(hsl) { + 'use strict'; return goog.color.rgbArrayToHex(goog.color.hslToRgb(hsl[0], hsl[1], hsl[2])); }; @@ -572,6 +596,7 @@ goog.color.hslArrayToHex = function(hsl) { * @return {!goog.color.Hsv} hsv representation of the color. */ goog.color.hexToHsv = function(hex) { + 'use strict'; return goog.color.rgbArrayToHsv(goog.color.hexToRgb(hex)); }; @@ -584,6 +609,7 @@ goog.color.hexToHsv = function(hex) { * @return {string} hex representation of the color. */ goog.color.hsvToHex = function(h, s, v) { + 'use strict'; return goog.color.rgbArrayToHex(goog.color.hsvToRgb(h, s, v)); }; @@ -594,6 +620,7 @@ goog.color.hsvToHex = function(h, s, v) { * @return {string} hex representation of the color. */ goog.color.hsvArrayToHex = function(hsv) { + 'use strict'; return goog.color.hsvToHex(hsv[0], hsv[1], hsv[2]); }; @@ -610,6 +637,7 @@ goog.color.hsvArrayToHex = function(hsv) { * @return {number} Distance between the two colors, in the range [0, 1]. */ goog.color.hslDistance = function(hsl1, hsl2) { + 'use strict'; var sl1, sl2; if (hsl1[2] <= 0.5) { sl1 = hsl1[1] * hsl1[2]; @@ -642,6 +670,7 @@ goog.color.hslDistance = function(hsl1, hsl2) { * @return {!goog.color.Rgb} Combined color represented in rgb. */ goog.color.blend = function(rgb1, rgb2, factor) { + 'use strict'; factor = goog.math.clamp(factor, 0, 1); return [ @@ -661,6 +690,7 @@ goog.color.blend = function(rgb1, rgb2, factor) { * @return {!goog.color.Rgb} Combined rgb color. */ goog.color.darken = function(rgb, factor) { + 'use strict'; var black = [0, 0, 0]; return goog.color.blend(black, rgb, factor); }; @@ -675,6 +705,7 @@ goog.color.darken = function(rgb, factor) { * @return {!goog.color.Rgb} Combined rgb color. */ goog.color.lighten = function(rgb, factor) { + 'use strict'; var white = [255, 255, 255]; return goog.color.blend(white, rgb, factor); }; @@ -690,6 +721,7 @@ goog.color.lighten = function(rgb, factor) { * @return {!goog.color.Rgb} Highest-contrast color represented by an array.. */ goog.color.highContrast = function(prime, suggestions) { + 'use strict'; var suggestionsWithDiff = []; for (var i = 0; i < suggestions.length; i++) { suggestionsWithDiff.push({ @@ -698,7 +730,10 @@ goog.color.highContrast = function(prime, suggestions) { goog.color.colorDiff_(suggestions[i], prime) }); } - suggestionsWithDiff.sort(function(a, b) { return b.diff - a.diff; }); + suggestionsWithDiff.sort(function(a, b) { + 'use strict'; + return b.diff - a.diff; + }); return suggestionsWithDiff[0].color; }; @@ -712,6 +747,7 @@ goog.color.highContrast = function(prime, suggestions) { * @private */ goog.color.yiqBrightness_ = function(rgb) { + 'use strict'; return Math.round((rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1000); }; @@ -725,6 +761,7 @@ goog.color.yiqBrightness_ = function(rgb) { * @private */ goog.color.yiqBrightnessDiff_ = function(rgb1, rgb2) { + 'use strict'; return Math.abs( goog.color.yiqBrightness_(rgb1) - goog.color.yiqBrightness_(rgb2)); }; @@ -739,6 +776,7 @@ goog.color.yiqBrightnessDiff_ = function(rgb1, rgb2) { * @private */ goog.color.colorDiff_ = function(rgb1, rgb2) { + 'use strict'; return Math.abs(rgb1[0] - rgb2[0]) + Math.abs(rgb1[1] - rgb2[1]) + Math.abs(rgb1[2] - rgb2[2]); }; diff --git a/closure/goog/debug/devcss/devcss.js b/closure/goog/debug/devcss/devcss.js index bacd33e965..ea7c792663 100644 --- a/closure/goog/debug/devcss/devcss.js +++ b/closure/goog/debug/devcss/devcss.js @@ -37,6 +37,7 @@ goog.require('goog.userAgent'); * @final */ goog.debug.DevCss = function(opt_userAgent, opt_userAgentVersion) { + 'use strict'; if (!opt_userAgent) { // Walks through the known goog.userAgents. if (goog.userAgent.IE) { @@ -113,6 +114,7 @@ goog.debug.DevCss = function(opt_userAgent, opt_userAgentVersion) { */ goog.debug.DevCss.prototype.activateBrowserSpecificCssRules = function( opt_enableIe6ReadyHandler) { + 'use strict'; var enableIe6EventHandler = (opt_enableIe6ReadyHandler !== undefined) ? opt_enableIe6ReadyHandler : true; @@ -183,6 +185,7 @@ goog.debug.DevCss.CssToken_ = { * @private */ goog.debug.DevCss.prototype.generateUserAgentTokens_ = function() { + 'use strict'; this.userAgentTokens_.ANY = goog.debug.DevCss.CssToken_.USERAGENT + goog.debug.DevCss.CssToken_.SEPARATOR + this.userAgent_; this.userAgentTokens_.EQUALS = @@ -211,6 +214,7 @@ goog.debug.DevCss.prototype.generateUserAgentTokens_ = function() { */ goog.debug.DevCss.prototype.getVersionNumberFromSelectorText_ = function( selectorText, userAgentToken) { + 'use strict'; var regex = new RegExp(userAgentToken + '([\\d\\.]+)'); var matches = regex.exec(selectorText); if (matches && matches.length == 2) { @@ -231,6 +235,7 @@ goog.debug.DevCss.prototype.getVersionNumberFromSelectorText_ = function( */ goog.debug.DevCss.prototype.getRuleVersionAndCompare_ = function( cssRule, token) { + 'use strict'; if (!cssRule.selectorText || !cssRule.selectorText.match(token)) { return; } @@ -256,7 +261,7 @@ goog.debug.DevCss.prototype.getRuleVersionAndCompare_ = function( */ goog.debug.DevCss.prototype.replaceBrowserSpecificClassNames_ = function( cssRule) { - + 'use strict'; // If we don't match the browser token, we can stop now. if (!cssRule.selectorText || !cssRule.selectorText.match(this.userAgentTokens_.ANY)) { @@ -351,6 +356,7 @@ goog.debug.DevCss.prototype.replaceBrowserSpecificClassNames_ = function( * @private */ goog.debug.DevCss.prototype.replaceIe6CombinedSelectors_ = function(cssRule) { + 'use strict'; // This match only ever works in IE because other UA's won't have our // IE6_SELECTOR_TEXT in the cssText property. if (cssRule.style && cssRule.style.cssText && @@ -379,6 +385,7 @@ goog.debug.DevCss.prototype.replaceIe6CombinedSelectors_ = function(cssRule) { * @private */ goog.debug.DevCss.prototype.getIe6CombinedSelectorText_ = function(cssText) { + 'use strict'; var regex = new RegExp( goog.debug.DevCss.CssToken_.IE6_SELECTOR_TEXT + '\\s*:\\s*\\"([^\\"]+)\\"', @@ -413,6 +420,7 @@ goog.debug.DevCss.prototype.getIe6CombinedSelectorText_ = function(cssText) { * @private */ goog.debug.DevCss.prototype.addIe6CombinedClassNames_ = function() { + 'use strict'; if (!this.ie6CombinedMatches_.length) { return; } diff --git a/closure/goog/debug/devcss/devcssrunner.js b/closure/goog/debug/devcss/devcssrunner.js index a7f508ce14..b6d2e72f5b 100644 --- a/closure/goog/debug/devcss/devcssrunner.js +++ b/closure/goog/debug/devcss/devcssrunner.js @@ -13,6 +13,7 @@ goog.provide('goog.debug.devCssRunner'); goog.require('goog.debug.DevCss'); (function() { - var devCssInstance = new goog.debug.DevCss(); - devCssInstance.activateBrowserSpecificCssRules(); +'use strict'; +var devCssInstance = new goog.debug.DevCss(); +devCssInstance.activateBrowserSpecificCssRules(); })(); diff --git a/closure/goog/dom/animationframe/animationframe.js b/closure/goog/dom/animationframe/animationframe.js index ee16c9abb3..436c79a81e 100644 --- a/closure/goog/dom/animationframe/animationframe.js +++ b/closure/goog/dom/animationframe/animationframe.js @@ -150,6 +150,7 @@ goog.dom.animationFrame.running_ = false; * @template THIS */ goog.dom.animationFrame.createTask = function(spec, opt_context) { + 'use strict'; var id = goog.dom.animationFrame.taskId_++; var measureTask = {id: id, fn: spec.measure, context: opt_context}; var mutateTask = {id: id, fn: spec.mutate, context: opt_context}; @@ -163,6 +164,7 @@ goog.dom.animationFrame.createTask = function(spec, opt_context) { }; return function() { + 'use strict'; // Save args and state. if (arguments.length > 0) { // The state argument goes last. That is kinda horrible but compatible @@ -198,6 +200,7 @@ goog.dom.animationFrame.createTask = function(spec, opt_context) { * @private */ goog.dom.animationFrame.runTasks_ = function() { + 'use strict'; goog.dom.animationFrame.running_ = true; goog.dom.animationFrame.requestedFrame_ = false; var tasksArray = goog.dom.animationFrame @@ -248,6 +251,7 @@ goog.dom.animationFrame.runTasks_ = function() { * additional frame. */ goog.dom.animationFrame.isRunning = function() { + 'use strict'; return goog.dom.animationFrame.running_; }; @@ -258,6 +262,7 @@ goog.dom.animationFrame.isRunning = function() { * @private */ goog.dom.animationFrame.requestAnimationFrame_ = function() { + 'use strict'; if (goog.dom.animationFrame.requestedFrame_) { return; } diff --git a/closure/goog/dom/animationframe/polyfill.js b/closure/goog/dom/animationframe/polyfill.js index b30f7f5a2b..7da0e39137 100644 --- a/closure/goog/dom/animationframe/polyfill.js +++ b/closure/goog/dom/animationframe/polyfill.js @@ -24,6 +24,7 @@ goog.dom.animationFrame.polyfill.ENABLED = * Installs the requestAnimationFrame (and cancelAnimationFrame) polyfill. */ goog.dom.animationFrame.polyfill.install = function() { + 'use strict'; if (goog.dom.animationFrame.polyfill.ENABLED) { const vendors = ['ms', 'moz', 'webkit', 'o']; let v; @@ -38,16 +39,21 @@ goog.dom.animationFrame.polyfill.install = function() { if (!goog.global.requestAnimationFrame) { let lastTime = 0; goog.global.requestAnimationFrame = function(callback) { + 'use strict'; const currTime = new Date().getTime(); const timeToCall = Math.max(0, 16 - (currTime - lastTime)); lastTime = currTime + timeToCall; return goog.global.setTimeout(function() { + 'use strict'; callback(currTime + timeToCall); }, timeToCall); }; if (!goog.global.cancelAnimationFrame) { - goog.global.cancelAnimationFrame = function(id) { clearTimeout(id); }; + goog.global.cancelAnimationFrame = function(id) { + 'use strict'; + clearTimeout(id); + }; } } } diff --git a/closure/goog/fx/css3/fx.js b/closure/goog/fx/css3/fx.js index 45ff61df4d..907b9fd36a 100644 --- a/closure/goog/fx/css3/fx.js +++ b/closure/goog/fx/css3/fx.js @@ -25,6 +25,7 @@ goog.require('goog.fx.css3.Transition'); */ goog.fx.css3.fade = function( element, duration, timing, startOpacity, endOpacity) { + 'use strict'; return new goog.fx.css3.Transition( element, duration, {'opacity': startOpacity}, {'opacity': endOpacity}, {property: 'opacity', duration: duration, timing: timing, delay: 0}); @@ -38,6 +39,7 @@ goog.fx.css3.fade = function( * @return {!goog.fx.css3.Transition} The transition object. */ goog.fx.css3.fadeIn = function(element, duration) { + 'use strict'; return goog.fx.css3.fade(element, duration, 'ease-out', 0, 1); }; @@ -49,5 +51,6 @@ goog.fx.css3.fadeIn = function(element, duration) { * @return {!goog.fx.css3.Transition} The transition object. */ goog.fx.css3.fadeOut = function(element, duration) { + 'use strict'; return goog.fx.css3.fade(element, duration, 'ease-in', 1, 0); }; diff --git a/closure/goog/fx/css3/transition.js b/closure/goog/fx/css3/transition.js index ce9014249f..2780d9c9bb 100644 --- a/closure/goog/fx/css3/transition.js +++ b/closure/goog/fx/css3/transition.js @@ -63,6 +63,7 @@ goog.require('goog.style.transition'); */ goog.fx.css3.Transition = function( element, duration, initialStyle, finalStyle, transitions) { + 'use strict'; goog.fx.css3.Transition.base(this, 'constructor'); /** @@ -106,6 +107,7 @@ goog.inherits(goog.fx.css3.Transition, goog.fx.TransitionBase); /** @override */ goog.fx.css3.Transition.prototype.play = function() { + 'use strict'; if (this.isPlaying()) { return false; } @@ -134,6 +136,7 @@ goog.fx.css3.Transition.prototype.play = function() { * @private */ goog.fx.css3.Transition.prototype.play_ = function() { + 'use strict'; // This measurement of the DOM element causes the browser to recalculate its // initial state before the transition starts. goog.style.getSize(this.element_); @@ -146,6 +149,7 @@ goog.fx.css3.Transition.prototype.play_ = function() { /** @override */ goog.fx.css3.Transition.prototype.stop = function() { + 'use strict'; if (!this.isPlaying()) return; this.stop_(true); @@ -158,6 +162,7 @@ goog.fx.css3.Transition.prototype.stop = function() { * @private */ goog.fx.css3.Transition.prototype.stop_ = function(stopped) { + 'use strict'; goog.style.transition.removeAll(this.element_); // Clear the timer. @@ -180,6 +185,7 @@ goog.fx.css3.Transition.prototype.stop_ = function(stopped) { /** @override */ goog.fx.css3.Transition.prototype.disposeInternal = function() { + 'use strict'; this.stop(); goog.fx.css3.Transition.base(this, 'disposeInternal'); }; @@ -190,5 +196,6 @@ goog.fx.css3.Transition.prototype.disposeInternal = function() { * @override */ goog.fx.css3.Transition.prototype.pause = function() { + 'use strict'; goog.asserts.assert(false, 'Css3 transitions does not support pause action.'); }; diff --git a/closure/goog/i18n/uchar/localnamefetcher.js b/closure/goog/i18n/uchar/localnamefetcher.js index d2dbf3a38c..f0d2a49b82 100644 --- a/closure/goog/i18n/uchar/localnamefetcher.js +++ b/closure/goog/i18n/uchar/localnamefetcher.js @@ -48,6 +48,7 @@ goog.i18n.uChar.LocalNameFetcher.prototype.prefetch = function(character) {}; /** @override */ goog.i18n.uChar.LocalNameFetcher.prototype.getName = function( character, callback) { + 'use strict'; var localName = goog.i18n.uCharNames.toName(character); if (!localName) { goog.log.warning( @@ -61,5 +62,6 @@ goog.i18n.uChar.LocalNameFetcher.prototype.getName = function( /** @override */ goog.i18n.uChar.LocalNameFetcher.prototype.isNameAvailable = function( character) { + 'use strict'; return !!goog.i18n.uCharNames.toName(character); }; diff --git a/closure/goog/i18n/uchar/remotenamefetcher.js b/closure/goog/i18n/uchar/remotenamefetcher.js index 822aa9a893..5e01faa82b 100644 --- a/closure/goog/i18n/uchar/remotenamefetcher.js +++ b/closure/goog/i18n/uchar/remotenamefetcher.js @@ -46,6 +46,7 @@ goog.require('goog.net.XhrIo'); * @final */ goog.i18n.uChar.RemoteNameFetcher = function(dataSourceUri) { + 'use strict'; goog.i18n.uChar.RemoteNameFetcher.base(this, 'constructor'); /** @@ -113,6 +114,7 @@ goog.i18n.uChar.RemoteNameFetcher.logger_ = /** @override */ goog.i18n.uChar.RemoteNameFetcher.prototype.disposeInternal = function() { + 'use strict'; goog.i18n.uChar.RemoteNameFetcher.base(this, 'disposeInternal'); this.prefetchXhrIo_.dispose(); this.getNameXhrIo_.dispose(); @@ -121,6 +123,7 @@ goog.i18n.uChar.RemoteNameFetcher.prototype.disposeInternal = function() { /** @override */ goog.i18n.uChar.RemoteNameFetcher.prototype.prefetch = function(characters) { + 'use strict'; // Abort the current request if there is one if (this.prefetchXhrIo_.isActive()) { goog.log.info( @@ -149,6 +152,7 @@ goog.i18n.uChar.RemoteNameFetcher.prototype.prefetch = function(characters) { * @private */ goog.i18n.uChar.RemoteNameFetcher.prototype.prefetchCallback_ = function() { + 'use strict'; this.processResponse_(this.prefetchXhrIo_); }; @@ -156,6 +160,7 @@ goog.i18n.uChar.RemoteNameFetcher.prototype.prefetchCallback_ = function() { /** @override */ goog.i18n.uChar.RemoteNameFetcher.prototype.getName = function( character, callback) { + 'use strict'; var codepoint = goog.i18n.uChar.toCharCode(character).toString(16); if (this.charNames_.has(codepoint)) { @@ -199,6 +204,7 @@ goog.i18n.uChar.RemoteNameFetcher.prototype.getName = function( */ goog.i18n.uChar.RemoteNameFetcher.prototype.getNameCallback_ = function( codepoint, callback) { + 'use strict'; this.processResponse_(this.getNameXhrIo_); var name = this.charNames_.has(codepoint) ? this.charNames_.get(codepoint) : null; @@ -213,6 +219,7 @@ goog.i18n.uChar.RemoteNameFetcher.prototype.getNameCallback_ = function( * @private */ goog.i18n.uChar.RemoteNameFetcher.prototype.processResponse_ = function(xhrIo) { + 'use strict'; if (!xhrIo.isSuccess()) { goog.log.error( goog.i18n.uChar.RemoteNameFetcher.logger_, @@ -263,6 +270,7 @@ goog.i18n.uChar.RemoteNameFetcher.RequestType_ = { */ goog.i18n.uChar.RemoteNameFetcher.prototype.fetch_ = function( requestType, requestInput, xhrIo) { + 'use strict'; var url = new goog.Uri(this.dataSourceUri_); url.setParameterValue(requestType, requestInput); url.setParameterValue('p', 'name'); @@ -275,5 +283,6 @@ goog.i18n.uChar.RemoteNameFetcher.prototype.fetch_ = function( /** @override */ goog.i18n.uChar.RemoteNameFetcher.prototype.isNameAvailable = function( character) { + 'use strict'; return true; }; diff --git a/closure/goog/labs/events/nondisposableeventtarget.js b/closure/goog/labs/events/nondisposableeventtarget.js index ded0173f77..33b9dff10d 100644 --- a/closure/goog/labs/events/nondisposableeventtarget.js +++ b/closure/goog/labs/events/nondisposableeventtarget.js @@ -59,6 +59,7 @@ goog.require('goog.object'); * @final */ goog.labs.events.NonDisposableEventTarget = function() { + 'use strict'; /** * Maps of event type to an array of listeners. * @private {!goog.events.ListenerMap} @@ -88,6 +89,7 @@ goog.labs.events.NonDisposableEventTarget.prototype.parentEventTarget_ = null; /** @override */ goog.labs.events.NonDisposableEventTarget.prototype.getParentEventTarget = function() { + 'use strict'; return this.parentEventTarget_; }; @@ -99,6 +101,7 @@ goog.labs.events.NonDisposableEventTarget.prototype.getParentEventTarget = */ goog.labs.events.NonDisposableEventTarget.prototype.setParentEventTarget = function(parent) { + 'use strict'; this.parentEventTarget_ = parent; }; @@ -106,6 +109,7 @@ goog.labs.events.NonDisposableEventTarget.prototype.setParentEventTarget = /** @override */ goog.labs.events.NonDisposableEventTarget.prototype.dispatchEvent = function( e) { + 'use strict'; this.assertInitialized_(); var ancestorsTree, ancestor = this.getParentEventTarget(); if (ancestor) { @@ -128,6 +132,7 @@ goog.labs.events.NonDisposableEventTarget.prototype.dispatchEvent = function( /** @override */ goog.labs.events.NonDisposableEventTarget.prototype.listen = function( type, listener, opt_useCapture, opt_listenerScope) { + 'use strict'; this.assertInitialized_(); return this.eventTargetListeners_.add( String(type), listener, false /* callOnce */, opt_useCapture, @@ -138,6 +143,7 @@ goog.labs.events.NonDisposableEventTarget.prototype.listen = function( /** @override */ goog.labs.events.NonDisposableEventTarget.prototype.listenOnce = function( type, listener, opt_useCapture, opt_listenerScope) { + 'use strict'; return this.eventTargetListeners_.add( String(type), listener, true /* callOnce */, opt_useCapture, opt_listenerScope); @@ -147,6 +153,7 @@ goog.labs.events.NonDisposableEventTarget.prototype.listenOnce = function( /** @override */ goog.labs.events.NonDisposableEventTarget.prototype.unlisten = function( type, listener, opt_useCapture, opt_listenerScope) { + 'use strict'; return this.eventTargetListeners_.remove( String(type), listener, opt_useCapture, opt_listenerScope); }; @@ -155,6 +162,7 @@ goog.labs.events.NonDisposableEventTarget.prototype.unlisten = function( /** @override */ goog.labs.events.NonDisposableEventTarget.prototype.unlistenByKey = function( key) { + 'use strict'; return this.eventTargetListeners_.removeByKey(key); }; @@ -162,6 +170,7 @@ goog.labs.events.NonDisposableEventTarget.prototype.unlistenByKey = function( /** @override */ goog.labs.events.NonDisposableEventTarget.prototype.removeAllListeners = function(opt_type) { + 'use strict'; return this.eventTargetListeners_.removeAll(opt_type); }; @@ -169,6 +178,7 @@ goog.labs.events.NonDisposableEventTarget.prototype.removeAllListeners = /** @override */ goog.labs.events.NonDisposableEventTarget.prototype.fireListeners = function( type, capture, eventObject) { + 'use strict'; // TODO(chrishenry): Original code avoids array creation when there // is no listener, so we do the same. If this optimization turns // out to be not required, we can replace this with @@ -201,6 +211,7 @@ goog.labs.events.NonDisposableEventTarget.prototype.fireListeners = function( /** @override */ goog.labs.events.NonDisposableEventTarget.prototype.getListeners = function( type, capture) { + 'use strict'; return this.eventTargetListeners_.getListeners(String(type), capture); }; @@ -208,6 +219,7 @@ goog.labs.events.NonDisposableEventTarget.prototype.getListeners = function( /** @override */ goog.labs.events.NonDisposableEventTarget.prototype.getListener = function( type, listener, capture, opt_listenerScope) { + 'use strict'; return this.eventTargetListeners_.getListener( String(type), listener, capture, opt_listenerScope); }; @@ -216,6 +228,7 @@ goog.labs.events.NonDisposableEventTarget.prototype.getListener = function( /** @override */ goog.labs.events.NonDisposableEventTarget.prototype.hasListener = function( opt_type, opt_capture) { + 'use strict'; var id = (opt_type !== undefined) ? String(opt_type) : undefined; return this.eventTargetListeners_.hasListener(id, opt_capture); }; @@ -227,6 +240,7 @@ goog.labs.events.NonDisposableEventTarget.prototype.hasListener = function( */ goog.labs.events.NonDisposableEventTarget.prototype.assertInitialized_ = function() { + 'use strict'; goog.asserts.assert( this.eventTargetListeners_, 'Event target is not initialized. Did you call the superclass ' + @@ -251,6 +265,7 @@ goog.labs.events.NonDisposableEventTarget.prototype.assertInitialized_ = */ goog.labs.events.NonDisposableEventTarget.dispatchEventInternal_ = function( target, e, opt_ancestorsTree) { + 'use strict'; var type = e.type || /** @type {string} */ (e); // If accepting a string or object, create a custom event object so that diff --git a/closure/goog/labs/events/touch.js b/closure/goog/labs/events/touch.js index 6a1161507f..e3ab840255 100644 --- a/closure/goog/labs/events/touch.js +++ b/closure/goog/labs/events/touch.js @@ -39,7 +39,7 @@ goog.labs.events.touch.TouchData; * @return {!goog.labs.events.touch.TouchData} */ goog.labs.events.touch.getTouchData = function(e) { - + 'use strict'; var source = e; goog.asserts.assert( goog.string.startsWith(e.type, 'touch') || diff --git a/closure/goog/labs/mock/mock.js b/closure/goog/labs/mock/mock.js index 0df9c67e18..c3940fc73e 100644 --- a/closure/goog/labs/mock/mock.js +++ b/closure/goog/labs/mock/mock.js @@ -44,6 +44,7 @@ goog.setTestOnly('goog.labs.mock'); * @return {!Object} The mocked object. */ goog.labs.mock.mock = function(objectOrClass) { + 'use strict'; // Go over properties of 'objectOrClass' and create a MockManager to // be used for stubbing out calls to methods. var mockObjectManager = new goog.labs.mock.MockObjectManager_(objectOrClass); @@ -60,6 +61,7 @@ goog.labs.mock.mock = function(objectOrClass) { * @return {!Function} The mocked function. */ goog.labs.mock.mockFunction = function(func) { + 'use strict'; var mockFuncManager = new goog.labs.mock.MockFunctionManager_(func); var mockedFunction = mockFuncManager.getMockedItem(); goog.asserts.assertFunction(mockedFunction); @@ -75,6 +77,7 @@ goog.labs.mock.mockFunction = function(func) { * @template T */ goog.labs.mock.mockConstructor = function(ctor) { + 'use strict'; var mockCtor = goog.labs.mock.mockFunction(ctor); // Copy class members from the real constructor to the mock. Do not copy @@ -97,6 +100,7 @@ goog.labs.mock.mockConstructor = function(ctor) { * @return {!Object} The spy object. */ goog.labs.mock.spy = function(obj) { + 'use strict'; // Go over properties of 'obj' and create a MockSpyManager_ to // be used for spying on calls to methods. var mockSpyManager = new goog.labs.mock.MockSpyManager_(obj); @@ -116,6 +120,7 @@ goog.labs.mock.spy = function(obj) { * @suppress {strictMissingProperties} Part of the go/strict_warnings_migration */ goog.labs.mock.verify = function(obj, opt_verificationMode) { + 'use strict'; var mode = opt_verificationMode || goog.labs.mock.verification.atLeast(1); obj.$verificationModeSetter(mode); @@ -157,6 +162,7 @@ goog.labs.mock.waitAndVerify = function(obj, ...verificationOrTimeoutModes) { * @return {string} The function name. */ goog.labs.mock.getFunctionName_ = function(func) { + 'use strict'; var funcName = goog.debug.getFunctionName(func); if (funcName == '' || funcName == '[Anonymous]') { funcName = '#anonymous' + goog.labs.mock.getUid(func); @@ -173,8 +179,10 @@ goog.labs.mock.getFunctionName_ = function(func) { * @return {string} The string representation of the method call. */ goog.labs.mock.formatMethodCall_ = function(methodName, opt_args) { + 'use strict'; opt_args = opt_args || []; opt_args = goog.array.map(opt_args, function(arg) { + 'use strict'; if (goog.isFunction(arg)) { var funcName = goog.labs.mock.getFunctionName_(arg); return ''; @@ -207,6 +215,7 @@ goog.labs.mock.uid_ = []; * @return {number} an unique id for the object. */ goog.labs.mock.getUid = function(obj) { + 'use strict'; var index = goog.array.indexOf(goog.labs.mock.uid_, obj); if (index == -1) { index = goog.labs.mock.uid_.length; @@ -226,12 +235,15 @@ goog.labs.mock.getUid = function(obj) { * @return {string} The string representation of the object. */ goog.labs.mock.formatValue_ = function(obj, opt_id) { + 'use strict'; var id = (opt_id !== undefined) ? opt_id : true; var previous = []; var output = []; var helper = function(obj) { + 'use strict'; var indentMultiline = function(output) { + 'use strict'; return output.replace(/\n/g, '\n'); }; @@ -300,6 +312,7 @@ goog.labs.mock.formatValue_ = function(obj, opt_id) { */ goog.labs.mock.VerificationError = function( recordedCalls, methodName, verificationMode, args) { + 'use strict'; var msg = goog.labs.mock.VerificationError.getVerificationErrorMsg_( recordedCalls, methodName, verificationMode, args); goog.labs.mock.VerificationError.base(this, 'constructor', msg); @@ -325,6 +338,7 @@ goog.labs.mock.VerificationError.prototype.name = 'VerificationError'; */ goog.labs.mock.TimeoutError = function( recordedCalls, methodName, verificationMode, args) { + 'use strict'; var msg = goog.labs.mock.TimeoutError.getTimeoutErrorMsg_( recordedCalls, methodName, verificationMode, args); goog.labs.mock.TimeoutError.base(this, 'constructor', msg); @@ -361,8 +375,9 @@ goog.labs.mock.PROTOTYPE_FIELDS_ = [ */ goog.labs.mock.VerificationError.getVerificationErrorMsg_ = function( recordedCalls, methodName, verificationMode, args) { - + 'use strict'; recordedCalls = goog.array.filter(recordedCalls, function(binding) { + 'use strict'; return binding.getMethodName() == methodName; }); @@ -395,6 +410,7 @@ goog.labs.mock.VerificationError.getVerificationErrorMsg_ = function( */ goog.labs.mock.TimeoutError.getTimeoutErrorMsg_ = function( recordedCalls, methodName, verificationMode, args) { + 'use strict'; var verificationErrorMsg = goog.labs.mock.VerificationError.getVerificationErrorMsg_( recordedCalls, methodName, verificationMode, args); @@ -417,6 +433,7 @@ goog.labs.mock.TimeoutError.getTimeoutErrorMsg_ = function( * @private */ goog.labs.mock.MockManager_ = function() { + 'use strict'; /** * Proxies the methods for the mocked object or class to execute the stubs. * @type {!Object} @@ -482,6 +499,7 @@ goog.labs.mock.MockManager_ = function() { */ goog.labs.mock.MockManager_.prototype.setVerificationMode_ = function( verificationMode) { + 'use strict'; this.verificationMode_ = verificationMode; }; @@ -493,6 +511,7 @@ goog.labs.mock.MockManager_.prototype.setVerificationMode_ = function( * @private */ goog.labs.mock.MockManager_.prototype.setTimeoutMode_ = function(timeoutMode) { + 'use strict'; this.timeoutMode_ = timeoutMode; }; @@ -507,6 +526,7 @@ goog.labs.mock.MockManager_.prototype.setTimeoutMode_ = function(timeoutMode) { */ goog.labs.mock.MockManager_.prototype.handleMockCall_ = function( methodName, var_args) { + 'use strict'; var args = goog.array.slice(arguments, 1); return new goog.labs.mock.StubBinderImpl_(this, methodName, args); }; @@ -519,6 +539,7 @@ goog.labs.mock.MockManager_.prototype.handleMockCall_ = function( * @return {!Object|!Function} The mock object. */ goog.labs.mock.MockManager_.prototype.getMockedItem = function() { + 'use strict'; return this.mockedItem; }; @@ -534,6 +555,7 @@ goog.labs.mock.MockManager_.prototype.getMockedItem = function() { */ goog.labs.mock.MockManager_.prototype.addBinding = function( methodName, args, func) { + 'use strict'; var binding = new goog.labs.mock.MethodBinding_(methodName, args, func); var sequentialStubsArray = [binding]; goog.array.insertAt(this.methodBindings, sequentialStubsArray, 0); @@ -557,7 +579,9 @@ goog.labs.mock.MockManager_.prototype.addBinding = function( */ goog.labs.mock.MockManager_.prototype.getNextBinding = function( methodName, args) { + 'use strict'; var bindings = goog.array.find(this.methodBindings, function(bindingArray) { + 'use strict'; return bindingArray[0].matches( methodName, args, false /* isVerification */); }); @@ -582,6 +606,7 @@ goog.labs.mock.MockManager_.prototype.getNextBinding = function( * @protected */ goog.labs.mock.MockManager_.prototype.getExecutor = function(methodName, args) { + 'use strict'; return this.getNextBinding(methodName, args); }; @@ -597,6 +622,7 @@ goog.labs.mock.MockManager_.prototype.getExecutor = function(methodName, args) { */ goog.labs.mock.MockManager_.prototype.executeStub = function( methodName, var_args) { + 'use strict'; var args = goog.array.slice(arguments, 1); var callRecord = this.recordCall_(methodName, args); @@ -623,6 +649,7 @@ goog.labs.mock.MockManager_.prototype.executeStub = function( * @private */ goog.labs.mock.MockManager_.prototype.recordCall_ = function(methodName, args) { + 'use strict'; var callRecord = new goog.labs.mock.MethodBinding_(methodName, args, goog.nullFunction); @@ -640,8 +667,10 @@ goog.labs.mock.MockManager_.prototype.recordCall_ = function(methodName, args) { */ goog.labs.mock.MockManager_.prototype.verifyInvocation = function( methodName, var_args) { + 'use strict'; var args = goog.array.slice(arguments, 1); var count = goog.array.count(this.callRecords_, function(binding) { + 'use strict'; return binding.matches(methodName, args, true /* isVerification */); }); @@ -719,6 +748,7 @@ goog.labs.mock.MockManager_.prototype.waitForCall = function( * go/strict_warnings_migration */ goog.labs.mock.MockObjectManager_ = function(objOrClass) { + 'use strict'; goog.labs.mock.MockObjectManager_.base(this, 'constructor'); /** @@ -828,6 +858,7 @@ goog.inherits(goog.labs.mock.MockObjectManager_, goog.labs.mock.MockManager_); * @private */ goog.labs.mock.MockSpyManager_ = function(obj) { + 'use strict'; goog.labs.mock.MockSpyManager_.base(this, 'constructor', obj); }; goog.inherits( @@ -844,6 +875,7 @@ goog.inherits( */ goog.labs.mock.MockSpyManager_.prototype.getNextBinding = function( methodName, args) { + 'use strict'; var stub = goog.labs.mock.MockSpyManager_.base( this, 'getNextBinding', methodName, args); @@ -869,6 +901,7 @@ goog.labs.mock.MockSpyManager_.prototype.getNextBinding = function( * go/strict_warnings_migration */ goog.labs.mock.MockFunctionManager_ = function(func) { + 'use strict'; goog.labs.mock.MockFunctionManager_.base(this, 'constructor'); this.func_ = func; @@ -918,9 +951,11 @@ goog.inherits(goog.labs.mock.MockFunctionManager_, goog.labs.mock.MockManager_); */ goog.labs.mock.MockFunctionManager_.prototype.useMockedFunctionName_ = function( nextFunc) { + 'use strict'; var mockFunctionManager = this; // Avoid using 'this' because this function may be called with 'new'. return function(var_args) { + 'use strict'; var args = goog.array.clone(arguments); var name = '#mockFor<' + goog.labs.mock.getFunctionName_(mockFunctionManager.func_) + '>'; @@ -980,6 +1015,7 @@ goog.labs.mock.StubBinder.prototype.thenReturn = goog.abstractMethod; * @private @constructor @struct @final */ goog.labs.mock.StubBinderImpl_ = function(mockManager, name, args) { + 'use strict'; /** * The mock manager instance. * @type {!goog.labs.mock.MockManager_} @@ -1014,6 +1050,7 @@ goog.labs.mock.StubBinderImpl_ = function(mockManager, name, args) { * @override */ goog.labs.mock.StubBinderImpl_.prototype.then = function(func) { + 'use strict'; if (this.sequentialStubsArray_.length) { this.sequentialStubsArray_.push( new goog.labs.mock.MethodBinding_(this.name_, this.args_, func)); @@ -1029,6 +1066,7 @@ goog.labs.mock.StubBinderImpl_.prototype.then = function(func) { * @override */ goog.labs.mock.StubBinderImpl_.prototype.thenReturn = function(value) { + 'use strict'; return this.then(goog.functions.constant(value)); }; @@ -1061,6 +1099,7 @@ goog.labs.mock.StubBinderImpl_.prototype.thenReturn = function(value) { * go/strict_warnings_migration */ goog.labs.mock.when = function(mockObject) { + 'use strict'; goog.asserts.assert(mockObject.$stubBinder, 'Stub binder cannot be null!'); return mockObject.$stubBinder; }; @@ -1079,6 +1118,7 @@ goog.labs.mock.when = function(mockObject) { * @private */ goog.labs.mock.MethodBinding_ = function(methodName, args, stub) { + 'use strict'; /** * The name of the method being stubbed. * @type {?string} @@ -1106,6 +1146,7 @@ goog.labs.mock.MethodBinding_ = function(methodName, args, stub) { * @return {!Function} The stub to be executed. */ goog.labs.mock.MethodBinding_.prototype.getStub = function() { + 'use strict'; return this.stub_; }; @@ -1116,6 +1157,7 @@ goog.labs.mock.MethodBinding_.prototype.getStub = function() { * as a method call. */ goog.labs.mock.MethodBinding_.prototype.toString = function() { + 'use strict'; return goog.labs.mock.formatMethodCall_(this.methodName_ || '', this.args_); }; @@ -1124,6 +1166,7 @@ goog.labs.mock.MethodBinding_.prototype.toString = function() { * @return {string} The method name for this binding. */ goog.labs.mock.MethodBinding_.prototype.getMethodName = function() { + 'use strict'; return this.methodName_ || ''; }; @@ -1140,6 +1183,7 @@ goog.labs.mock.MethodBinding_.prototype.getMethodName = function() { */ goog.labs.mock.MethodBinding_.prototype.matches = function( methodName, args, isVerification) { + 'use strict'; var specs = isVerification ? args : this.args_; var calls = isVerification ? this.args_ : args; @@ -1147,6 +1191,7 @@ goog.labs.mock.MethodBinding_.prototype.matches = function( // objects. return this.methodName_ == methodName && goog.array.equals(calls, specs, function(arg, spec) { + 'use strict'; // Duck-type to see if this is an object that implements the // goog.labs.testing.Matcher interface. if (spec && goog.isFunction(spec.matches)) { diff --git a/closure/goog/labs/mock/timeoutmode.js b/closure/goog/labs/mock/timeoutmode.js index 1f99c6b709..243707ee48 100644 --- a/closure/goog/labs/mock/timeoutmode.js +++ b/closure/goog/labs/mock/timeoutmode.js @@ -38,5 +38,6 @@ goog.labs.mock.timeout.TimeoutMode = class TimeoutMode { * @return {!goog.labs.mock.timeout.TimeoutMode} */ goog.labs.mock.timeout.timeout = function(duration) { + 'use strict'; return new goog.labs.mock.timeout.TimeoutMode(duration); }; diff --git a/closure/goog/proto/proto.js b/closure/goog/proto/proto.js index fdebaaa20f..a55b3665ab 100644 --- a/closure/goog/proto/proto.js +++ b/closure/goog/proto/proto.js @@ -28,6 +28,7 @@ goog.proto.serializer_ = null; * @return {string} The serialized protocol buffer string. */ goog.proto.serialize = function(object) { + 'use strict'; if (!goog.proto.serializer_) { goog.proto.serializer_ = new goog.proto.Serializer; } diff --git a/closure/goog/proto/serializer.js b/closure/goog/proto/serializer.js index 67e1351869..e7f26df0fb 100644 --- a/closure/goog/proto/serializer.js +++ b/closure/goog/proto/serializer.js @@ -27,6 +27,7 @@ goog.require('goog.string'); * @final */ goog.proto.Serializer = function() { + 'use strict'; goog.json.Serializer.call(this); }; goog.inherits(goog.proto.Serializer, goog.json.Serializer); @@ -40,6 +41,7 @@ goog.inherits(goog.proto.Serializer, goog.json.Serializer); * @override */ goog.proto.Serializer.prototype.serializeArray = function(arr, sb) { + 'use strict'; var l = arr.length; sb.push('['); var emptySlots = 0; diff --git a/closure/goog/testing/proto2/proto2.js b/closure/goog/testing/proto2/proto2.js index 12682aea59..acd907035f 100644 --- a/closure/goog/testing/proto2/proto2.js +++ b/closure/goog/testing/proto2/proto2.js @@ -26,6 +26,7 @@ goog.require('goog.testing.asserts'); * @private */ goog.testing.proto2.findDifferences_ = function(expected, actual, path) { + 'use strict'; var fields = expected.getDescriptor().getFields(); for (var i = 0; i < fields.length; i++) { var field = fields[i]; @@ -101,6 +102,7 @@ goog.testing.proto2.findDifferences_ = function(expected, actual, path) { */ goog.testing.proto2.assertEquals = function( expected, actual, opt_failureMessage) { + 'use strict'; var failureSummary = opt_failureMessage || ''; if (!(expected instanceof goog.proto2.Message) || !(actual instanceof goog.proto2.Message)) { @@ -130,6 +132,7 @@ goog.testing.proto2.assertEquals = function( * @template MessageType */ goog.testing.proto2.fromObject = function(messageCtor, json) { + 'use strict'; var serializer = new goog.proto2.ObjectSerializer( goog.proto2.ObjectSerializer.KeyOption.NAME); var message = new messageCtor; diff --git a/closure/goog/testing/storage/fakemechanism.js b/closure/goog/testing/storage/fakemechanism.js index 13fdbaf6e8..7a7d9b9233 100644 --- a/closure/goog/testing/storage/fakemechanism.js +++ b/closure/goog/testing/storage/fakemechanism.js @@ -24,6 +24,7 @@ goog.require('goog.structs.Map'); * @final */ goog.testing.storage.FakeMechanism = function() { + 'use strict'; /** * @type {goog.structs.Map} * @private @@ -37,12 +38,14 @@ goog.inherits( /** @override */ goog.testing.storage.FakeMechanism.prototype.set = function(key, value) { + 'use strict'; this.storage_.set(key, value); }; /** @override */ goog.testing.storage.FakeMechanism.prototype.get = function(key) { + 'use strict'; return /** @type {?string} */ ( this.storage_.get(key, null /* default value */)); }; @@ -50,11 +53,13 @@ goog.testing.storage.FakeMechanism.prototype.get = function(key) { /** @override */ goog.testing.storage.FakeMechanism.prototype.remove = function(key) { + 'use strict'; this.storage_.remove(key); }; /** @override */ goog.testing.storage.FakeMechanism.prototype.__iterator__ = function(opt_keys) { + 'use strict'; return this.storage_.__iterator__(opt_keys); }; diff --git a/closure/goog/testing/style/layoutasserts.js b/closure/goog/testing/style/layoutasserts.js index 4d76af1b9b..c2559102b0 100644 --- a/closure/goog/testing/style/layoutasserts.js +++ b/closure/goog/testing/style/layoutasserts.js @@ -26,6 +26,7 @@ goog.require('goog.testing.style'); * @param {Element=} opt_b The element when a comment string is present. */ var assertIsVisible = function(a, opt_b) { + 'use strict'; _validateArguments(1, arguments); var element = nonCommentArg(1, 1, arguments); @@ -42,6 +43,7 @@ var assertIsVisible = function(a, opt_b) { * @param {Element=} opt_b The element when a comment string is present. */ var assertNotVisible = function(a, opt_b) { + 'use strict'; _validateArguments(1, arguments); var element = nonCommentArg(1, 1, arguments); if (!element) { @@ -63,6 +65,7 @@ var assertNotVisible = function(a, opt_b) { * @param {Element=} opt_c The second element if comment string is present. */ var assertIntersect = function(a, b, opt_c) { + 'use strict'; _validateArguments(2, arguments); var element = nonCommentArg(1, 2, arguments); var otherElement = nonCommentArg(2, 2, arguments); @@ -82,6 +85,7 @@ var assertIntersect = function(a, b, opt_c) { * @param {Element=} opt_c The second element if comment string is present. */ var assertNoIntersect = function(a, b, opt_c) { + 'use strict'; _validateArguments(2, arguments); var element = nonCommentArg(1, 2, arguments); var otherElement = nonCommentArg(2, 2, arguments); @@ -101,6 +105,7 @@ var assertNoIntersect = function(a, b, opt_c) { * @param {Element=} opt_c The second element if comment string is present. */ var assertWidth = function(a, b, opt_c) { + 'use strict'; _validateArguments(2, arguments); var element = nonCommentArg(1, 2, arguments); var width = nonCommentArg(2, 2, arguments); @@ -126,6 +131,7 @@ var assertWidth = function(a, b, opt_c) { * @param {number=} opt_d The tolerance if comment string is present. */ var assertWidthWithinTolerance = function(a, b, c, opt_d) { + 'use strict'; _validateArguments(3, arguments); var element = nonCommentArg(1, 3, arguments); var width = nonCommentArg(2, 3, arguments); @@ -150,6 +156,7 @@ var assertWidthWithinTolerance = function(a, b, c, opt_d) { * @param {Element=} opt_c The second element if comment string is present. */ var assertHeight = function(a, b, opt_c) { + 'use strict'; _validateArguments(2, arguments); var element = nonCommentArg(1, 2, arguments); var height = nonCommentArg(2, 2, arguments); @@ -175,6 +182,7 @@ var assertHeight = function(a, b, opt_c) { * @param {number=} opt_d The tolerance if comment string is present. */ var assertHeightWithinTolerance = function(a, b, c, opt_d) { + 'use strict'; _validateArguments(3, arguments); var element = nonCommentArg(1, 3, arguments); var height = nonCommentArg(2, 3, arguments); @@ -199,6 +207,7 @@ var assertHeightWithinTolerance = function(a, b, c, opt_d) { * @param {Element=} opt_c The second element if comment string is present. */ var assertIsLeftOf = function(a, b, opt_c) { + 'use strict'; _validateArguments(2, arguments); var element = nonCommentArg(1, 2, arguments); var otherElement = nonCommentArg(2, 2, arguments); @@ -219,6 +228,7 @@ var assertIsLeftOf = function(a, b, opt_c) { * @param {Element=} opt_c The second element if comment string is present. */ var assertIsStrictlyLeftOf = function(a, b, opt_c) { + 'use strict'; _validateArguments(2, arguments); var element = nonCommentArg(1, 2, arguments); var otherElement = nonCommentArg(2, 2, arguments); @@ -240,6 +250,7 @@ var assertIsStrictlyLeftOf = function(a, b, opt_c) { * @param {Element=} opt_c The second element if comment string is present. */ var assertIsAbove = function(a, b, opt_c) { + 'use strict'; _validateArguments(2, arguments); var element = nonCommentArg(1, 2, arguments); var otherElement = nonCommentArg(2, 2, arguments); @@ -260,6 +271,7 @@ var assertIsAbove = function(a, b, opt_c) { * @param {Element=} opt_c The second element if comment string is present. */ var assertIsStrictlyAbove = function(a, b, opt_c) { + 'use strict'; _validateArguments(2, arguments); var element = nonCommentArg(1, 2, arguments); var otherElement = nonCommentArg(2, 2, arguments); @@ -282,6 +294,7 @@ var assertIsStrictlyAbove = function(a, b, opt_c) { * @param {Element=} opt_c The second element if comment string is present. */ var assertContained = function(a, b, opt_c) { + 'use strict'; _validateArguments(2, arguments); var element = nonCommentArg(1, 2, arguments); var otherElement = nonCommentArg(2, 2, arguments); @@ -305,5 +318,6 @@ var assertContained = function(a, b, opt_c) { */ goog.testing.style.layoutasserts.isWithinThreshold_ = function( val1, val2, threshold) { + 'use strict'; return Math.abs(val1 - val2) <= threshold; }; diff --git a/closure/goog/testing/style/style.js b/closure/goog/testing/style/style.js index d30065faad..425c5c42ff 100644 --- a/closure/goog/testing/style/style.js +++ b/closure/goog/testing/style/style.js @@ -26,6 +26,7 @@ goog.require('goog.style'); * intersect. */ goog.testing.style.intersects = function(element, otherElement) { + 'use strict'; var elementRect = goog.style.getBounds(element); var otherElementRect = goog.style.getBounds(otherElement); return goog.math.Rect.intersects(elementRect, otherElementRect); @@ -38,6 +39,7 @@ goog.testing.style.intersects = function(element, otherElement) { * @return {boolean} Whether the element has visible dimensions. */ goog.testing.style.hasVisibleDimensions = function(element) { + 'use strict'; var elSize = goog.style.getSize(element); var shortest = elSize.getShortest(); if (shortest <= 0) { @@ -55,6 +57,7 @@ goog.testing.style.hasVisibleDimensions = function(element) { * @return {boolean} Whether the CSS style of the element renders it visible. */ goog.testing.style.isVisible = function(element) { + 'use strict'; if (!goog.dom.isInDocument(element)) { return false; } @@ -69,6 +72,7 @@ goog.testing.style.isVisible = function(element) { * @return {boolean} Whether the element is on the screen. */ goog.testing.style.isOnScreen = function(el) { + 'use strict'; var doc = goog.dom.getDomHelper(el).getDocument(); var viewport = goog.style.getVisibleRectForElement(doc.body); var viewportRect = goog.math.Rect.createFromBox(viewport); diff --git a/closure/goog/timer/timer.js b/closure/goog/timer/timer.js index b4ec441529..64b640a1c9 100644 --- a/closure/goog/timer/timer.js +++ b/closure/goog/timer/timer.js @@ -30,6 +30,7 @@ goog.requireType('goog.Thenable'); * @extends {goog.events.EventTarget} */ goog.Timer = function(opt_interval, opt_timerObject) { + 'use strict'; goog.events.EventTarget.call(this); /** @@ -133,6 +134,7 @@ goog.Timer.prototype.timer_ = null; * @return {number} interval Number of ms between ticks. */ goog.Timer.prototype.getInterval = function() { + 'use strict'; return this.interval_; }; @@ -142,6 +144,7 @@ goog.Timer.prototype.getInterval = function() { * @param {number} interval Number of ms between ticks. */ goog.Timer.prototype.setInterval = function(interval) { + 'use strict'; this.interval_ = interval; if (this.timer_ && this.enabled) { // Stop and then start the timer to reset the interval. @@ -158,6 +161,7 @@ goog.Timer.prototype.setInterval = function(interval) { * @private */ goog.Timer.prototype.tick_ = function() { + 'use strict'; if (this.enabled) { var elapsed = goog.now() - this.last_; if (elapsed > 0 && elapsed < this.interval_ * goog.Timer.intervalScale) { @@ -189,6 +193,7 @@ goog.Timer.prototype.tick_ = function() { * Dispatches the TICK event. This is its own method so subclasses can override. */ goog.Timer.prototype.dispatchTick = function() { + 'use strict'; this.dispatchEvent(goog.Timer.TICK); }; @@ -197,6 +202,7 @@ goog.Timer.prototype.dispatchTick = function() { * Starts the timer. */ goog.Timer.prototype.start = function() { + 'use strict'; this.enabled = true; // If there is no interval already registered, start it now @@ -223,6 +229,7 @@ goog.Timer.prototype.start = function() { * Stops the timer. */ goog.Timer.prototype.stop = function() { + 'use strict'; this.enabled = false; if (this.timer_) { this.timerObject_.clearTimeout(this.timer_); @@ -233,6 +240,7 @@ goog.Timer.prototype.stop = function() { /** @override */ goog.Timer.prototype.disposeInternal = function() { + 'use strict'; goog.Timer.superClass_.disposeInternal.call(this); this.stop(); delete this.timerObject_; @@ -261,6 +269,7 @@ goog.Timer.TICK = 'tick'; * @template SCOPE */ goog.Timer.callOnce = function(listener, opt_delay, opt_handler) { + 'use strict'; if (goog.isFunction(listener)) { if (opt_handler) { listener = goog.bind(listener, opt_handler); @@ -288,6 +297,7 @@ goog.Timer.callOnce = function(listener, opt_delay, opt_handler) { * @param {?number} timerId A timer ID. */ goog.Timer.clear = function(timerId) { + 'use strict'; goog.Timer.defaultTimerObject.clearTimeout(timerId); }; @@ -301,16 +311,21 @@ goog.Timer.clear = function(timerId) { * @template RESULT */ goog.Timer.promise = function(delay, opt_result) { + 'use strict'; var timerKey = null; return new goog .Promise(function(resolve, reject) { - timerKey = - goog.Timer.callOnce(function() { resolve(opt_result); }, delay); + 'use strict'; + timerKey = goog.Timer.callOnce(function() { + 'use strict'; + resolve(opt_result); + }, delay); if (timerKey == goog.Timer.INVALID_TIMEOUT_ID_) { reject(new Error('Failed to schedule timer.')); } }) .thenCatch(function(error) { + 'use strict'; // Clear the timer. The most likely reason is "cancel" signal. goog.Timer.clear(timerKey); throw error; diff --git a/closure/goog/window/window.js b/closure/goog/window/window.js index be71dd81a8..66cd7afeb3 100644 --- a/closure/goog/window/window.js +++ b/closure/goog/window/window.js @@ -50,6 +50,7 @@ goog.window.DEFAULT_POPUP_TARGET = 'google_popup'; * @private */ goog.window.createFakeWindow_ = function() { + 'use strict'; return /** @type {!Window} */ ({}); }; @@ -93,6 +94,7 @@ goog.window.createFakeWindow_ = function() { * a cross-origin window has been opened. */ goog.window.open = function(linkRef, opt_options, opt_parentWin) { + 'use strict'; if (!opt_options) { opt_options = {}; } @@ -275,6 +277,7 @@ goog.window.open = function(linkRef, opt_options, opt_parentWin) { * opened. */ goog.window.openBlank = function(opt_message, opt_options, opt_parentWin) { + 'use strict'; // Open up a window with the loading message and nothing else. // This will be interpreted as HTML content type with a missing doctype // and html/body tags, but is otherwise acceptable. @@ -327,6 +330,7 @@ goog.window.openBlank = function(opt_message, opt_options, opt_parentWin) { * @return {boolean} true if the window was not popped up, false if it was. */ goog.window.popup = function(linkRef, opt_options) { + 'use strict'; if (!opt_options) { opt_options = {}; } diff --git a/third_party/closure/goog/mochikit/async/deferred.js b/third_party/closure/goog/mochikit/async/deferred.js index 626fc7da76..a57f9f75ce 100644 --- a/third_party/closure/goog/mochikit/async/deferred.js +++ b/third_party/closure/goog/mochikit/async/deferred.js @@ -74,6 +74,7 @@ goog.require('goog.debug.Error'); * @template VALUE */ goog.async.Deferred = function(opt_onCancelFunction, opt_defaultScope) { + 'use strict'; /** * Entries in the sequence are arrays containing a callback, an errback, and * an optional scope. The callback or errback in an entry may be null. @@ -226,6 +227,7 @@ goog.async.Deferred.LONG_STACK_TRACES = * effect on a branch without opt_propagateCancel set to true. */ goog.async.Deferred.prototype.cancel = function(opt_deepCancel) { + 'use strict'; if (!this.hasFired()) { if (this.parent_) { // Get rid of the parent reference before potentially running the parent's @@ -262,6 +264,7 @@ goog.async.Deferred.prototype.cancel = function(opt_deepCancel) { * @private */ goog.async.Deferred.prototype.branchCancel_ = function() { + 'use strict'; this.branches_--; if (this.branches_ <= 0) { this.cancel(); @@ -278,6 +281,7 @@ goog.async.Deferred.prototype.branchCancel_ = function() { * @private */ goog.async.Deferred.prototype.continue_ = function(isSuccess, res) { + 'use strict'; this.blocked_ = false; this.updateResult_(isSuccess, res); }; @@ -292,6 +296,7 @@ goog.async.Deferred.prototype.continue_ = function(isSuccess, res) { * @private */ goog.async.Deferred.prototype.updateResult_ = function(isSuccess, res) { + 'use strict'; this.fired_ = true; this.result_ = res; this.hadError_ = !isSuccess; @@ -306,6 +311,7 @@ goog.async.Deferred.prototype.updateResult_ = function(isSuccess, res) { * @throws {Error} If this has already been fired. */ goog.async.Deferred.prototype.check_ = function() { + 'use strict'; if (this.hasFired()) { if (!this.silentlyCanceled_) { throw new goog.async.Deferred.AlreadyCalledError(this); @@ -321,6 +327,7 @@ goog.async.Deferred.prototype.check_ = function() { * @param {VALUE=} opt_result The starting result. */ goog.async.Deferred.prototype.callback = function(opt_result) { + 'use strict'; this.check_(); this.assertNotDeferred_(opt_result); this.updateResult_(true /* isSuccess */, opt_result); @@ -333,6 +340,7 @@ goog.async.Deferred.prototype.callback = function(opt_result) { * @param {*=} opt_result The starting error. */ goog.async.Deferred.prototype.errback = function(opt_result) { + 'use strict'; this.check_(); this.assertNotDeferred_(opt_result); this.makeStackTraceLong_(opt_result); @@ -357,6 +365,7 @@ goog.async.Deferred.unhandledErrorHandler_ = (e) => { * will fail with `throw`. */ goog.async.Deferred.setUnhandledErrorHandler = function(handler) { + 'use strict'; goog.async.Deferred.unhandledErrorHandler_ = handler; }; @@ -370,6 +379,7 @@ goog.async.Deferred.setUnhandledErrorHandler = function(handler) { * @suppress {missingProperties} error.stack */ goog.async.Deferred.prototype.makeStackTraceLong_ = function(error) { + 'use strict'; if (!goog.async.Deferred.LONG_STACK_TRACES) { return; } @@ -390,6 +400,7 @@ goog.async.Deferred.prototype.makeStackTraceLong_ = function(error) { * @private */ goog.async.Deferred.prototype.assertNotDeferred_ = function(obj) { + 'use strict'; goog.asserts.assert( !(obj instanceof goog.async.Deferred), 'An execution sequence may not be initiated with a blocking Deferred.'); @@ -416,6 +427,7 @@ goog.async.Deferred.prototype.assertNotDeferred_ = function(obj) { * @template T */ goog.async.Deferred.prototype.addCallback = function(cb, opt_scope) { + 'use strict'; return this.addCallbacks(cb, null, opt_scope); }; @@ -440,6 +452,7 @@ goog.async.Deferred.prototype.addCallback = function(cb, opt_scope) { * @template T */ goog.async.Deferred.prototype.addErrback = function(eb, opt_scope) { + 'use strict'; return this.addCallbacks(null, eb, opt_scope); }; @@ -453,6 +466,7 @@ goog.async.Deferred.prototype.addErrback = function(eb, opt_scope) { * @template T */ goog.async.Deferred.prototype.addBoth = function(f, opt_scope) { + 'use strict'; return this.addCallbacks(f, f, opt_scope); }; @@ -466,7 +480,9 @@ goog.async.Deferred.prototype.addBoth = function(f, opt_scope) { * @template T */ goog.async.Deferred.prototype.addFinally = function(f, opt_scope) { + 'use strict'; return this.addCallbacks(f, function(err) { + 'use strict'; var result = f.call(/** @type {?} */ (this), err); if (result === undefined) { throw err; @@ -493,6 +509,7 @@ goog.async.Deferred.prototype.addFinally = function(f, opt_scope) { * @template T */ goog.async.Deferred.prototype.addCallbacks = function(cb, eb, opt_scope) { + 'use strict'; goog.asserts.assert(!this.blocking_, 'Blocking Deferreds can not be re-used'); this.sequence_.push([cb, eb, opt_scope]); if (this.hasFired()) { @@ -513,16 +530,19 @@ goog.async.Deferred.prototype.addCallbacks = function(cb, eb, opt_scope) { * * @override */ -goog.async.Deferred.prototype.then = function(opt_onFulfilled, opt_onRejected, - opt_context) { +goog.async.Deferred.prototype.then = function( + opt_onFulfilled, opt_onRejected, opt_context) { + 'use strict'; var resolve, reject; var promise = new goog.Promise(function(res, rej) { + 'use strict'; // Copying resolvers to outer scope, so that they are available when the // deferred callback fires (which may be synchronous). resolve = res; reject = rej; }); this.addCallbacks(resolve, function(reason) { + 'use strict'; if (reason instanceof goog.async.Deferred.CanceledError) { promise.cancel(); } else { @@ -543,6 +563,7 @@ goog.Thenable.addImplementation(goog.async.Deferred); * @return {!goog.async.Deferred} This Deferred. */ goog.async.Deferred.prototype.chainDeferred = function(otherDeferred) { + 'use strict'; this.addCallbacks( otherDeferred.callback, otherDeferred.errback, otherDeferred); return this; @@ -562,9 +583,11 @@ goog.async.Deferred.prototype.chainDeferred = function(otherDeferred) { * @return {!goog.async.Deferred} This Deferred. */ goog.async.Deferred.prototype.awaitDeferred = function(otherDeferred) { + 'use strict'; if (!(otherDeferred instanceof goog.async.Deferred)) { // The Thenable case. return this.addCallback(function() { + 'use strict'; return otherDeferred; }); } @@ -588,6 +611,7 @@ goog.async.Deferred.prototype.awaitDeferred = function(otherDeferred) { * the computed result from this stage in the execution sequence. */ goog.async.Deferred.prototype.branch = function(opt_propagateCancel) { + 'use strict'; var d = new goog.async.Deferred(); this.chainDeferred(d); if (opt_propagateCancel) { @@ -603,6 +627,7 @@ goog.async.Deferred.prototype.branch = function(opt_propagateCancel) { * Deferred by invoking `callback` or `errback`. */ goog.async.Deferred.prototype.hasFired = function() { + 'use strict'; return this.fired_; }; @@ -615,6 +640,7 @@ goog.async.Deferred.prototype.hasFired = function() { * @protected */ goog.async.Deferred.prototype.isError = function(res) { + 'use strict'; return res instanceof Error; }; @@ -624,7 +650,9 @@ goog.async.Deferred.prototype.isError = function(res) { * @private */ goog.async.Deferred.prototype.hasErrback_ = function() { + 'use strict'; return goog.array.some(this.sequence_, function(sequenceRow) { + 'use strict'; // The errback is the second element in the array. return goog.isFunction(sequenceRow[1]); }); @@ -639,6 +667,7 @@ goog.async.Deferred.prototype.hasErrback_ = function() { * primitives. */ goog.async.Deferred.prototype.getLastValueForMigration = function() { + 'use strict'; return (this.hasFired() && !this.hadError_) ? this.result_ : undefined; }; @@ -651,6 +680,7 @@ goog.async.Deferred.prototype.getLastValueForMigration = function() { * @private */ goog.async.Deferred.prototype.fire_ = function() { + 'use strict'; if (this.unhandledErrorId_ && this.hasFired() && this.hasErrback_()) { // It is possible to add errbacks after the Deferred has fired. If a new // errback is added immediately after the Deferred encountered an unhandled @@ -744,6 +774,7 @@ goog.async.Deferred.prototype.fire_ = function() { * @return {!goog.async.Deferred} The new Deferred. */ goog.async.Deferred.succeed = function(opt_result) { + 'use strict'; var d = new goog.async.Deferred(); d.callback(opt_result); return d; @@ -764,12 +795,15 @@ goog.async.Deferred.succeed = function(opt_result) { * @template T */ goog.async.Deferred.fromPromise = function(promise) { + 'use strict'; var d = new goog.async.Deferred(); promise.then( function(value) { + 'use strict'; d.callback(value); }, function(error) { + 'use strict'; d.errback(error); }); return d; @@ -783,6 +817,7 @@ goog.async.Deferred.fromPromise = function(promise) { * @return {!goog.async.Deferred} The new Deferred. */ goog.async.Deferred.fail = function(res) { + 'use strict'; var d = new goog.async.Deferred(); d.errback(res); return d; @@ -795,6 +830,7 @@ goog.async.Deferred.fail = function(res) { * @return {!goog.async.Deferred} The new Deferred. */ goog.async.Deferred.canceled = function() { + 'use strict'; var d = new goog.async.Deferred(); d.cancel(); return d; @@ -834,6 +870,7 @@ goog.async.Deferred.canceled = function() { * @template T */ goog.async.Deferred.when = function(value, callback, opt_scope) { + 'use strict'; if (value instanceof goog.async.Deferred) { return value.branch(true).addCallback(callback, opt_scope); } else { @@ -851,6 +888,7 @@ goog.async.Deferred.when = function(value, callback, opt_scope) { * @extends {goog.debug.Error} */ goog.async.Deferred.AlreadyCalledError = function(deferred) { + 'use strict'; goog.debug.Error.call(this); /** @@ -880,6 +918,7 @@ goog.async.Deferred.AlreadyCalledError.prototype.name = 'AlreadyCalledError'; * @extends {goog.debug.Error} */ goog.async.Deferred.CanceledError = function(deferred) { + 'use strict'; goog.debug.Error.call(this); /** @@ -911,6 +950,7 @@ goog.async.Deferred.CanceledError.prototype.name = 'CanceledError'; * @struct */ goog.async.Deferred.Error_ = function(error) { + 'use strict'; /** @const @private {number} */ this.id_ = goog.global.setTimeout(goog.bind(this.throwError, this), 0); @@ -924,7 +964,9 @@ goog.async.Deferred.Error_ = function(error) { * deferred errors. */ goog.async.Deferred.Error_.prototype.throwError = function() { - goog.asserts.assert(goog.async.Deferred.errorMap_[this.id_], + 'use strict'; + goog.asserts.assert( + goog.async.Deferred.errorMap_[this.id_], 'Cannot throw an error that is not scheduled.'); delete goog.async.Deferred.errorMap_[this.id_]; goog.async.Deferred.unhandledErrorHandler_(this.error_); @@ -935,6 +977,7 @@ goog.async.Deferred.Error_.prototype.throwError = function() { * Resets the error throw timer. */ goog.async.Deferred.Error_.prototype.resetTimer = function() { + 'use strict'; goog.global.clearTimeout(this.id_); }; @@ -953,6 +996,7 @@ goog.async.Deferred.errorMap_ = {}; * @private */ goog.async.Deferred.scheduleError_ = function(error) { + 'use strict'; var deferredError = new goog.async.Deferred.Error_(error); goog.async.Deferred.errorMap_[deferredError.id_] = deferredError; return deferredError.id_; @@ -965,6 +1009,7 @@ goog.async.Deferred.scheduleError_ = function(error) { * @private */ goog.async.Deferred.unscheduleError_ = function(id) { + 'use strict'; var error = goog.async.Deferred.errorMap_[id]; if (error) { error.resetTimer(); @@ -978,6 +1023,7 @@ goog.async.Deferred.unscheduleError_ = function(id) { * scheduled errors, one will be thrown immediately to make this function fail. */ goog.async.Deferred.assertNoErrors = function() { + 'use strict'; var map = goog.async.Deferred.errorMap_; for (var key in map) { var error = map[key]; diff --git a/third_party/closure/goog/mochikit/async/deferredlist.js b/third_party/closure/goog/mochikit/async/deferredlist.js index 12ae59005b..44f61c6584 100644 --- a/third_party/closure/goog/mochikit/async/deferredlist.js +++ b/third_party/closure/goog/mochikit/async/deferredlist.js @@ -70,9 +70,9 @@ goog.require('goog.async.Deferred'); goog.async.DeferredList = function( list, opt_fireOnOneCallback, opt_fireOnOneErrback, opt_consumeErrors, opt_canceler, opt_defaultScope) { - - goog.async.DeferredList.base(this, 'constructor', - opt_canceler, opt_defaultScope); + 'use strict'; + goog.async.DeferredList.base( + this, 'constructor', opt_canceler, opt_defaultScope); /** * The list of Deferred objects to wait for. @@ -148,7 +148,7 @@ goog.inherits(goog.async.DeferredList, goog.async.Deferred); */ goog.async.DeferredList.prototype.handleCallback_ = function( index, success, result) { - + 'use strict'; this.numFinished_++; this.deferredResults_[index] = [success, result]; @@ -172,6 +172,7 @@ goog.async.DeferredList.prototype.handleCallback_ = function( /** @override */ goog.async.DeferredList.prototype.errback = function(res) { + 'use strict'; goog.async.DeferredList.base(this, 'errback', res); // On error, cancel any pending requests. @@ -194,8 +195,10 @@ goog.async.DeferredList.prototype.errback = function(res) { * if they all succeed, or the error result of the first input to fail. */ goog.async.DeferredList.gatherResults = function(list) { - return new goog.async.DeferredList(list, false, true). - addCallback(function(results) { + 'use strict'; + return new goog.async.DeferredList(list, false, true) + .addCallback(function(results) { + 'use strict'; var output = []; for (var i = 0; i < results.length; i++) { output[i] = results[i][1];