Skip to content

Commit ac34244

Browse files
committed
Update closure-library to fba2eb76bc0e695952480de932d71cc1b7dd9f1f
1 parent c36ef93 commit ac34244

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+806
-393
lines changed

third_party/closure/goog/a11y/aria/aria.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ goog.a11y.aria.setState = function(element, stateName, value) {
171171
*/
172172
goog.a11y.aria.toggleState = function(el, attr) {
173173
var val = goog.a11y.aria.getState(el, attr);
174-
if (!goog.string.isEmptySafe(val) && !(val == 'true' || val == 'false')) {
174+
if (!goog.string.isEmptyOrWhitespace(goog.string.makeSafe(val)) &&
175+
!(val == 'true' || val == 'false')) {
175176
goog.a11y.aria.removeState(el, /** @type {!goog.a11y.aria.State} */ (attr));
176177
return;
177178
}

third_party/closure/goog/asserts/asserts.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,9 @@ goog.asserts.assertObjectPrototypeIsIntact = function() {
355355
*/
356356
goog.asserts.getType_ = function(value) {
357357
if (value instanceof Function) {
358-
// TODO(martone): unquote this after the next Closure Compiler release.
359-
return value['displayName'] || value.name || 'unknown type name';
358+
return value.displayName || value.name || 'unknown type name';
360359
} else if (value instanceof Object) {
361-
return value.constructor['displayName'] || value.constructor.name ||
360+
return value.constructor.displayName || value.constructor.name ||
362361
Object.prototype.toString.call(value);
363362
} else {
364363
return value === null ? 'null' : typeof value;

third_party/closure/goog/base.js

Lines changed: 82 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,17 @@ goog.constructNamespace_ = function(name, opt_obj) {
274274
};
275275

276276

277+
/**
278+
* Module identifier validation regexp.
279+
* Note: This is a conservative check, it is very possible to be more lienent,
280+
* the primary exclusion here is "/" and "\" and a leading ".", these
281+
* restrictions are intended to leave the door open for using goog.require
282+
* with relative file paths rather than module identifiers.
283+
* @private
284+
*/
285+
goog.VALID_MODULE_RE_ = /^[a-zA-Z_$][a-zA-Z0-9._$]*$/;
286+
287+
277288
/**
278289
* goog.module serves two purposes:
279290
* - marks a file that must be loaded as a module
@@ -296,7 +307,9 @@ goog.constructNamespace_ = function(name, opt_obj) {
296307
* "goog.package.part", is expected but not required.
297308
*/
298309
goog.module = function(name) {
299-
if (!goog.isString(name) || !name) {
310+
if (!goog.isString(name) ||
311+
!name ||
312+
name.search(goog.VALID_MODULE_RE_) == -1) {
300313
throw Error('Invalid module identifier');
301314
}
302315
if (!goog.isInModuleLoader_()) {
@@ -888,58 +901,6 @@ if (goog.DEPENDENCIES_ENABLED) {
888901
goog.queuedModules_ = [];
889902

890903

891-
/**
892-
* Retrieve and execute a module.
893-
* @param {string} src Script source URL.
894-
* @private
895-
*/
896-
goog.retrieveAndExecModule_ = function(src) {
897-
// The full but non-canonicalized URL for later use.
898-
var originalPath = src;
899-
900-
// Canonicalize the path, removing any /./ or /../ since Chrome's debugging
901-
// console doesn't auto-canonicalize XHR loads as it does <script> srcs.
902-
var separator;
903-
while ((separator = src.indexOf('/./')) != -1) {
904-
src = src.substr(0, separator) + src.substr(separator + '/.'.length);
905-
}
906-
while ((separator = src.indexOf('/../')) != -1) {
907-
var previousComponent = src.lastIndexOf('/', separator - 1);
908-
src = src.substr(0, previousComponent) +
909-
src.substr(separator + '/..'.length);
910-
}
911-
912-
var importScript = goog.global.CLOSURE_IMPORT_SCRIPT ||
913-
goog.writeScriptTag_;
914-
915-
var scriptText = null;
916-
917-
var xhr = new goog.global['XMLHttpRequest']();
918-
919-
/** @this {Object} */
920-
xhr.onload = function() {
921-
scriptText = this.responseText;
922-
};
923-
xhr.open('get', src, false);
924-
xhr.send();
925-
926-
scriptText = xhr.responseText;
927-
928-
if (scriptText != null) {
929-
var execModuleScript = goog.wrapModule_(src, scriptText);
930-
var isOldIE = goog.IS_OLD_IE_;
931-
if (isOldIE) {
932-
goog.dependencies_.deferred[originalPath] = execModuleScript;
933-
goog.queuedModules_.push(originalPath);
934-
} else {
935-
importScript(src, execModuleScript);
936-
}
937-
} else {
938-
throw new Error('load of ' + src + 'failed');
939-
}
940-
};
941-
942-
943904
/**
944905
* Return an appropriate module text. Suitable to insert into
945906
* a script tag (that is unescaped).
@@ -1324,6 +1285,74 @@ if (goog.DEPENDENCIES_ENABLED) {
13241285
}
13251286

13261287

1288+
/**
1289+
* Normalize a file path by removing redundant ".." and extraneous "." file
1290+
* path components.
1291+
* @param {string} path
1292+
* @return {string}
1293+
* @private
1294+
*/
1295+
goog.normalizePath_ = function(path) {
1296+
var components = path.split('/');
1297+
var i = 0;
1298+
while (i < components.length) {
1299+
if (components[i] == '.') {
1300+
components.splice(i, 1);
1301+
} else if (i && components[i] == '..' &&
1302+
components[i - 1] && components[i - 1] != '..') {
1303+
components.splice(--i, 2);
1304+
} else {
1305+
i++;
1306+
}
1307+
}
1308+
return components.join('/');
1309+
};
1310+
1311+
1312+
/**
1313+
* Retrieve and execute a module.
1314+
* @param {string} src Script source URL.
1315+
* @private
1316+
*/
1317+
goog.retrieveAndExecModule_ = function(src) {
1318+
if (!COMPILED) {
1319+
// The full but non-canonicalized URL for later use.
1320+
var originalPath = src;
1321+
// Canonicalize the path, removing any /./ or /../ since Chrome's debugging
1322+
// console doesn't auto-canonicalize XHR loads as it does <script> srcs.
1323+
src = goog.normalizePath_(src);
1324+
1325+
var importScript = goog.global.CLOSURE_IMPORT_SCRIPT ||
1326+
goog.writeScriptTag_;
1327+
1328+
var scriptText = null;
1329+
1330+
var xhr = new goog.global['XMLHttpRequest']();
1331+
1332+
/** @this {Object} */
1333+
xhr.onload = function() {
1334+
scriptText = this.responseText;
1335+
};
1336+
xhr.open('get', src, false);
1337+
xhr.send();
1338+
1339+
scriptText = xhr.responseText;
1340+
1341+
if (scriptText != null) {
1342+
var execModuleScript = goog.wrapModule_(src, scriptText);
1343+
var isOldIE = goog.IS_OLD_IE_;
1344+
if (isOldIE) {
1345+
goog.dependencies_.deferred[originalPath] = execModuleScript;
1346+
goog.queuedModules_.push(originalPath);
1347+
} else {
1348+
importScript(src, execModuleScript);
1349+
}
1350+
} else {
1351+
throw new Error('load of ' + src + 'failed');
1352+
}
1353+
}
1354+
};
1355+
13271356

13281357
//==============================================================================
13291358
// Language Enhancements

third_party/closure/goog/cssom/cssom.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ goog.cssom.getAllCssText = function(opt_styleSheet) {
6868
*/
6969
goog.cssom.getAllCssStyleRules = function(opt_styleSheet) {
7070
var styleSheet = opt_styleSheet || document.styleSheets;
71-
return /** @type {Array<CSSStyleRule>} */ (
71+
return /** @type {!Array<CSSStyleRule>} */ (
7272
goog.cssom.getAllCss_(styleSheet, false));
7373
};
7474

@@ -146,7 +146,7 @@ goog.cssom.getAllCssStyleSheets = function(opt_styleSheet,
146146
// to see if there are styleSheets buried in there.
147147
// If we have a CSSStyleSheet within CssRules.
148148
var cssRuleList = goog.cssom.getCssRulesFromStyleSheet(
149-
/** @type {CSSStyleSheet} */ (styleSheet));
149+
/** @type {!CSSStyleSheet} */ (styleSheet));
150150
if (cssRuleList && cssRuleList.length) {
151151
// Chrome does not evaluate cssRuleList[i] to undefined when i >=n;
152152
// so we use a (i < n) check instead of cssRuleList[i] in the loop below

third_party/closure/goog/cssom/iframe/style.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ goog.cssom.iframe.style.getBackgroundContext = function(element) {
941941
while ((ancestor = ancestor.parentNode) &&
942942
ancestor.nodeType == goog.dom.NodeType.ELEMENT) {
943943
var computedStyle = goog.cssom.iframe.style.getComputedStyleObject_(
944-
/** @type {Element} */ (ancestor));
944+
/** @type {!Element} */ (ancestor));
945945
// Copy background color if a non-transparent value is found.
946946
var backgroundColorValue = computedStyle['backgroundColor'];
947947
if (!goog.cssom.iframe.style.isTransparentValue_(backgroundColorValue)) {
@@ -962,8 +962,8 @@ goog.cssom.iframe.style.getBackgroundContext = function(element) {
962962
element, currentIframeWindow);
963963
var frameElement = currentIframeWindow.frameElement;
964964
var iframeRelativePosition = goog.style.getRelativePosition(
965-
/** @type {Element} */ (frameElement),
966-
/** @type {Element} */ (ancestor));
965+
/** @type {!Element} */ (frameElement),
966+
/** @type {!Element} */ (ancestor));
967967
var iframeBorders = goog.style.getBorderBox(frameElement);
968968
relativePosition.x += iframeRelativePosition.x + iframeBorders.left;
969969
relativePosition.y += iframeRelativePosition.y + iframeBorders.top;

third_party/closure/goog/datasource/fastdatanode.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ goog.ds.FastDataNode.prototype.getJsObject = function() {
299299
* @return {goog.ds.FastDataNode} Clone of this data node.
300300
*/
301301
goog.ds.FastDataNode.prototype.clone = function() {
302-
return /** @type {goog.ds.FastDataNode} */(goog.ds.FastDataNode.fromJs(
302+
return /** @type {!goog.ds.FastDataNode} */(goog.ds.FastDataNode.fromJs(
303303
this.getJsObject(), this.getDataName()));
304304
};
305305

third_party/closure/goog/db/transaction.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,21 @@ goog.db.Transaction = function(tx, db) {
7272
// TODO(user): remove these casts once the externs file is updated to
7373
// correctly reflect that IDBTransaction extends EventTarget
7474
this.eventHandler_.listen(
75-
/** @type {EventTarget} */ (this.tx_),
75+
/** @type {!EventTarget} */ (this.tx_),
7676
'complete',
7777
goog.bind(
7878
this.dispatchEvent,
7979
this,
8080
goog.db.Transaction.EventTypes.COMPLETE));
8181
this.eventHandler_.listen(
82-
/** @type {EventTarget} */ (this.tx_),
82+
/** @type {!EventTarget} */ (this.tx_),
8383
'abort',
8484
goog.bind(
8585
this.dispatchEvent,
8686
this,
8787
goog.db.Transaction.EventTypes.ABORT));
8888
this.eventHandler_.listen(
89-
/** @type {EventTarget} */ (this.tx_),
89+
/** @type {!EventTarget} */ (this.tx_),
9090
'error',
9191
this.dispatchError_);
9292
};

third_party/closure/goog/deps.js

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

third_party/closure/goog/dom/browserrange/ierange.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ goog.dom.browserrange.IeRange.insertNode_ = function(clone, node,
900900

901901
clone.collapse(before);
902902
node = goog.dom.browserrange.IeRange.pasteElement_(clone,
903-
/** @type {Element} */ (node), opt_domHelper);
903+
/** @type {!Element} */ (node), opt_domHelper);
904904

905905
// If we didn't want an element, unwrap the element and return the node.
906906
if (isNonElement) {

third_party/closure/goog/dom/browserrange/w3crange.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ goog.dom.browserrange.W3cRange.prototype.getValidHtml = function() {
227227
container.parentNode;
228228

229229
var html = goog.dom.getOuterHtml(
230-
/** @type {Element} */ (container.cloneNode(false)));
230+
/** @type {!Element} */ (container.cloneNode(false)));
231231
return html.replace('>', '>' + result);
232232
};
233233

0 commit comments

Comments
 (0)