From 1315171ecc37fc358d4905feb34911fbad2a025c Mon Sep 17 00:00:00 2001 From: sethg Date: Thu, 2 May 2019 23:10:15 +0200 Subject: [PATCH 1/5] Update OL distribution to v4.6.5 --- src/exercises/lib/ol/ol-debug.js | 109434 ++++++++++++++-------------- src/exercises/lib/ol/ol.css | 2 +- src/exercises/lib/ol/ol.js | 2045 +- 3 files changed, 57516 insertions(+), 53965 deletions(-) diff --git a/src/exercises/lib/ol/ol-debug.js b/src/exercises/lib/ol/ol-debug.js index 5513c54..eab35d6 100644 --- a/src/exercises/lib/ol/ol-debug.js +++ b/src/exercises/lib/ol/ol-debug.js @@ -1,6 +1,6 @@ -// OpenLayers 3. See https://openlayers.org/ -// License: https://raw.githubusercontent.com/openlayers/ol3/master/LICENSE.md -// Version: v3.20.1 +// OpenLayers. See https://openlayers.org/ +// License: https://raw.githubusercontent.com/openlayers/openlayers/master/LICENSE.md +// Version: v4.6.5 ;(function (root, factory) { if (typeof exports === "object") { module.exports = factory(); @@ -30,19 +30,19 @@ this.CLOSURE_NO_DEPS = true; /** * @fileoverview Bootstrap for the Google JS Library (Closure). * - * In uncompiled mode base.js will write out Closure's deps file, unless the - * global CLOSURE_NO_DEPS is set to true. This allows projects to - * include their own deps file(s) from different locations. + * In uncompiled mode base.js will attempt to load Closure's deps file, unless + * the global CLOSURE_NO_DEPS is set to true. This allows projects + * to include their own deps file(s) from different locations. * - * @author arv@google.com (Erik Arvidsson) + * Avoid including base.js more than once. This is strictly discouraged and not + * supported. goog.require(...) won't work properly in that case. * * @provideGoog */ /** - * @define {boolean} Overridden to true by the compiler when - * --process_closure_primitives is specified. + * @define {boolean} Overridden to true by the compiler. */ var COMPILED = false; @@ -105,8 +105,6 @@ goog.global.CLOSURE_DEFINES; /** * Returns true if the specified value is not undefined. - * WARNING: Do not use this to test if an object has a property. Use the in - * operator instead. * * @param {?} val Variable to test. * @return {boolean} Whether variable is defined. @@ -117,6 +115,35 @@ goog.isDef = function(val) { return val !== void 0; }; +/** + * Returns true if the specified value is a string. + * @param {?} val Variable to test. + * @return {boolean} Whether variable is a string. + */ +goog.isString = function(val) { + return typeof val == 'string'; +}; + + +/** + * Returns true if the specified value is a boolean. + * @param {?} val Variable to test. + * @return {boolean} Whether variable is boolean. + */ +goog.isBoolean = function(val) { + return typeof val == 'boolean'; +}; + + +/** + * Returns true if the specified value is a number. + * @param {?} val Variable to test. + * @return {boolean} Whether variable is a number. + */ +goog.isNumber = function(val) { + return typeof val == 'number'; +}; + /** * Builds an object structure for the provided namespace path, ensuring that @@ -126,7 +153,7 @@ goog.isDef = function(val) { * @param {string} name name of the object that this file defines. * @param {*=} opt_object the object to expose at the end of the path. * @param {Object=} opt_objectToExportTo The object to add the path to; default - * is |goog.global|. + * is `goog.global`. * @private */ goog.exportPath_ = function(name, opt_object, opt_objectToExportTo) { @@ -140,17 +167,11 @@ goog.exportPath_ = function(name, opt_object, opt_objectToExportTo) { cur.execScript('var ' + parts[0]); } - // Certain browsers cannot parse code in the form for((a in b); c;); - // This pattern is produced by the JSCompiler when it collapses the - // statement above into the conditional loop below. To prevent this from - // happening, use a for-loop and reserve the init logic as below. - - // Parentheses added to eliminate strict JS warning in Firefox. for (var part; parts.length && (part = parts.shift());) { if (!parts.length && goog.isDef(opt_object)) { // last part and we have an object; use it cur[part] = opt_object; - } else if (cur[part]) { + } else if (cur[part] && cur[part] !== Object.prototype[part]) { cur = cur[part]; } else { cur = cur[part] = {}; @@ -173,11 +194,16 @@ goog.define = function(name, defaultValue) { var value = defaultValue; if (!COMPILED) { if (goog.global.CLOSURE_UNCOMPILED_DEFINES && + // Anti DOM-clobbering runtime check (b/37736576). + /** @type {?} */ (goog.global.CLOSURE_UNCOMPILED_DEFINES).nodeType === + undefined && Object.prototype.hasOwnProperty.call( goog.global.CLOSURE_UNCOMPILED_DEFINES, name)) { value = goog.global.CLOSURE_UNCOMPILED_DEFINES[name]; } else if ( goog.global.CLOSURE_DEFINES && + // Anti DOM-clobbering runtime check (b/37736576). + /** @type {?} */ (goog.global.CLOSURE_DEFINES).nodeType === undefined && Object.prototype.hasOwnProperty.call( goog.global.CLOSURE_DEFINES, name)) { value = goog.global.CLOSURE_DEFINES[name]; @@ -189,11 +215,12 @@ goog.define = function(name, defaultValue) { /** * @define {boolean} DEBUG is provided as a convenience so that debugging code - * that should not be included in a production js_binary can be easily stripped - * by specifying --define goog.DEBUG=false to the JSCompiler. For example, most - * toString() methods should be declared inside an "if (goog.DEBUG)" conditional - * because they are generally used for debugging purposes and it is difficult - * for the JSCompiler to statically determine whether they are used. + * that should not be included in a production. It can be easily stripped + * by specifying --define goog.DEBUG=false to the Closure Compiler aka + * JSCompiler. For example, most toString() methods should be declared inside an + * "if (goog.DEBUG)" conditional because they are generally used for debugging + * purposes and it is difficult for the JSCompiler to statically determine + * whether they are used. */ goog.define('goog.DEBUG', true); @@ -201,7 +228,7 @@ goog.define('goog.DEBUG', true); /** * @define {string} LOCALE defines the locale being used for compilation. It is * used to select locale specific data to be compiled in js binary. BUILD rule - * can specify this value by "--define goog.LOCALE=" as JSCompiler + * can specify this value by "--define goog.LOCALE=" as a compiler * option. * * Take into account that the locale code format is important. You should use @@ -215,7 +242,8 @@ goog.define('goog.DEBUG', true); * For language codes you should use values defined by ISO 693-1. See it here * http://www.w3.org/WAI/ER/IG/ert/iso639.htm. There is only one exception from * this rule: the Hebrew language. For legacy reasons the old code (iw) should - * be used instead of the new code (he), see http://wiki/Main/IIISynonyms. + * be used instead of the new code (he). + * */ goog.define('goog.LOCALE', 'en'); // default to en @@ -229,7 +257,7 @@ goog.define('goog.LOCALE', 'en'); // default to en * * If your JavaScript can be loaded by a third party site and you are wary about * relying on non-standard implementations, specify - * "--define goog.TRUSTED_SITE=false" to the JSCompiler. + * "--define goog.TRUSTED_SITE=false" to the compiler. */ goog.define('goog.TRUSTED_SITE', true); @@ -283,13 +311,13 @@ goog.define('goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING', false); */ goog.provide = function(name) { if (goog.isInModuleLoader_()) { - throw Error('goog.provide can not be used within a goog.module.'); + throw new Error('goog.provide can not be used within a goog.module.'); } if (!COMPILED) { // Ensure that the same namespace isn't provided twice. // A goog.module/goog.provide maps a goog.require to a specific file if (goog.isProvided_(name)) { - throw Error('Namespace "' + name + '" already declared.'); + throw new Error('Namespace "' + name + '" already declared.'); } } @@ -360,17 +388,24 @@ goog.VALID_MODULE_RE_ = /^[a-zA-Z_$][a-zA-Z0-9._$]*$/; * * @param {string} name Namespace provided by this file in the form * "goog.package.part", is expected but not required. + * @return {void} */ goog.module = function(name) { if (!goog.isString(name) || !name || name.search(goog.VALID_MODULE_RE_) == -1) { - throw Error('Invalid module identifier'); + throw new Error('Invalid module identifier'); } if (!goog.isInModuleLoader_()) { - throw Error('Module ' + name + ' has been loaded incorrectly.'); + throw new Error( + 'Module ' + name + ' has been loaded incorrectly. Note, ' + + 'modules cannot be loaded as normal scripts. They require some kind of ' + + 'pre-processing step. You\'re likely trying to load a module via a ' + + 'script tag or as a part of a concatenated bundle without rewriting the ' + + 'module. For more info see: ' + + 'https://github.com/google/closure-library/wiki/goog.module:-an-ES6-module-like-alternative-to-goog.provide.'); } if (goog.moduleLoaderState_.moduleName) { - throw Error('goog.module may only be called once per module.'); + throw new Error('goog.module may only be called once per module.'); } // Store the module name for the loader. @@ -379,7 +414,7 @@ goog.module = function(name) { // Ensure that the same namespace isn't provided twice. // A goog.module/goog.provide maps a goog.require to a specific file if (goog.isProvided_(name)) { - throw Error('Namespace "' + name + '" already declared.'); + throw new Error('Namespace "' + name + '" already declared.'); } delete goog.implicitNamespaces_[name]; } @@ -408,14 +443,14 @@ goog.module.get = function(name) { */ goog.module.getInternal_ = function(name) { if (!COMPILED) { - if (goog.isProvided_(name)) { - // goog.require only return a value with-in goog.module files. - return name in goog.loadedModules_ ? goog.loadedModules_[name] : - goog.getObjectByName(name); - } else { - return null; + if (name in goog.loadedModules_) { + return goog.loadedModules_[name]; + } else if (!goog.implicitNamespaces_[name]) { + var ns = goog.getObjectByName(name); + return ns != null ? ns : null; } } + return null; }; @@ -447,7 +482,7 @@ goog.module.declareLegacyNamespace = function() { 'within a goog.module'); } if (!COMPILED && !goog.moduleLoaderState_.moduleName) { - throw Error( + throw new Error( 'goog.module must be called prior to ' + 'goog.module.declareLegacyNamespace.'); } @@ -469,7 +504,7 @@ goog.module.declareLegacyNamespace = function() { goog.setTestOnly = function(opt_message) { if (goog.DISALLOW_TEST_ONLY_CODE) { opt_message = opt_message || ''; - throw Error( + throw new Error( 'Importing test-only code into non-debug environment' + (opt_message ? ': ' + opt_message : '.')); } @@ -488,6 +523,9 @@ goog.setTestOnly = function(opt_message) { * into the JavaScript binary. If it is required elsewhere, it will be type * checked as normal. * + * Before using goog.forwardDeclare, please read the documentation at + * https://github.com/google/closure-compiler/wiki/Bad-Type-Annotation to + * understand the options and tradeoffs when working with forward declarations. * * @param {string} name The namespace to forward declare in the form of * "goog.package.part". @@ -550,10 +588,9 @@ if (!COMPILED) { goog.getObjectByName = function(name, opt_obj) { var parts = name.split('.'); var cur = opt_obj || goog.global; - for (var part; part = parts.shift();) { - if (goog.isDefAndNotNull(cur[part])) { - cur = cur[part]; - } else { + for (var i = 0; i < parts.length; i++) { + cur = cur[parts[i]]; + if (!goog.isDefAndNotNull(cur)) { return null; } } @@ -627,7 +664,7 @@ goog.addDependency = function(relPath, provides, requires, opt_loadFlags) { // Externally: https://developers.google.com/closure/library/docs/depswriter // // Because of legacy clients, the DOM loader can't be easily removed from -// base.js. Work is being done to make it disableable or replaceable for +// base.js. Work was done to make it disableable or replaceable for // different environments (DOM-less JavaScript interpreters like Rhino or V8, // for example). See bootstrap/ for more information. @@ -659,8 +696,7 @@ goog.logToConsole_ = function(msg) { /** * Implements a system for the dynamic resolution of dependencies that works in * parallel with the BUILD system. Note that all calls to goog.require will be - * stripped by the JSCompiler when the --process_closure_primitives option is - * used. + * stripped by the compiler. * @see goog.provide * @param {string} name Namespace to include (as was given in goog.provide()) in * the form "goog.package.part". @@ -668,7 +704,7 @@ goog.logToConsole_ = function(msg) { * module otherwise null. */ goog.require = function(name) { - // If the object already exists we do not need do do anything. + // If the object already exists we do not need to do anything. if (!COMPILED) { if (goog.ENABLE_DEBUG_LOADER && goog.IS_OLD_IE_) { goog.maybeProcessDeferredDep_(name); @@ -677,23 +713,20 @@ goog.require = function(name) { if (goog.isProvided_(name)) { if (goog.isInModuleLoader_()) { return goog.module.getInternal_(name); - } else { - return null; } - } - - if (goog.ENABLE_DEBUG_LOADER) { + } else if (goog.ENABLE_DEBUG_LOADER) { var path = goog.getPathFromDeps_(name); if (path) { goog.writeScripts_(path); - return null; + } else { + var errorMessage = 'goog.require could not find: ' + name; + goog.logToConsole_(errorMessage); + + throw new Error(errorMessage); } } - var errorMessage = 'goog.require could not find: ' + name; - goog.logToConsole_(errorMessage); - - throw Error(errorMessage); + return null; } }; @@ -713,7 +746,8 @@ goog.global.CLOSURE_BASE_PATH; /** - * Whether to write out Closure's deps file. By default, the deps are written. + * Whether to attempt to load Closure's deps file. By default, when uncompiled, + * deps files will attempt to be loaded. * @type {boolean|undefined} */ goog.global.CLOSURE_NO_DEPS; @@ -746,14 +780,11 @@ goog.nullFunction = function() {}; * Now if a subclass of Foo fails to override bar(), an error will be thrown * when bar() is invoked. * - * Note: This does not take the name of the function to override as an argument - * because that would make it more difficult to obfuscate our JavaScript code. - * * @type {!Function} * @throws {Error} when invoked to indicate the method should be overridden. */ goog.abstractMethod = function() { - throw Error('unimplemented abstract method'); + throw new Error('unimplemented abstract method'); }; @@ -764,6 +795,10 @@ goog.abstractMethod = function() { * method to. */ goog.addSingletonGetter = function(ctor) { + // instance_ is immediately set to prevent issues with sealed constructors + // such as are encountered when a constructor is returned as the export object + // of a goog.module in unoptimized code. + ctor.instance_ = undefined; ctor.getInstance = function() { if (ctor.instance_) { return ctor.instance_; @@ -885,7 +920,9 @@ if (goog.DEPENDENCIES_ENABLED) { * @private */ goog.findBasePath_ = function() { - if (goog.isDef(goog.global.CLOSURE_BASE_PATH)) { + if (goog.isDef(goog.global.CLOSURE_BASE_PATH) && + // Anti DOM-clobbering runtime check (b/37736576). + goog.isString(goog.global.CLOSURE_BASE_PATH)) { goog.basePath = goog.global.CLOSURE_BASE_PATH; return; } else if (!goog.inHtmlDocument_()) { @@ -893,7 +930,13 @@ if (goog.DEPENDENCIES_ENABLED) { } /** @type {Document} */ var doc = goog.global.document; - var scripts = doc.getElementsByTagName('SCRIPT'); + // If we have a currentScript available, use it exclusively. + var currentScript = doc.currentScript; + if (currentScript) { + var scripts = [currentScript]; + } else { + var scripts = doc.getElementsByTagName('SCRIPT'); + } // Search backwards since the current script is in almost all cases the one // that has base.js. for (var i = scripts.length - 1; i >= 0; --i) { @@ -934,6 +977,17 @@ if (goog.DEPENDENCIES_ENABLED) { !!(!goog.global.atob && goog.global.document && goog.global.document.all); + /** + * Whether IE9 or earlier is waiting on a dependency. This ensures that + * deferred modules that have no non-deferred dependencies actually get + * loaded, since if we defer them and then never pull in a non-deferred + * script, then `goog.loadQueuedModules_` will never be called. Instead, + * if not waiting on anything we simply don't defer in the first place. + * @private {boolean} + */ + goog.oldIeWaiting_ = false; + + /** * Given a URL initiate retrieval and execution of a script that needs * pre-processing. @@ -1018,6 +1072,7 @@ if (goog.DEPENDENCIES_ENABLED) { goog.maybeProcessDeferredPath_(path); } } + goog.oldIeWaiting_ = false; }; @@ -1043,8 +1098,9 @@ if (goog.DEPENDENCIES_ENABLED) { goog.isDeferredModule_ = function(name) { var path = goog.getPathFromDeps_(name); var loadFlags = path && goog.dependencies_.loadFlags[path] || {}; + var languageLevel = loadFlags['lang'] || 'es3'; if (path && (loadFlags['module'] == 'goog' || - goog.needsTranspile_(loadFlags['lang']))) { + goog.needsTranspile_(languageLevel))) { var abspath = goog.basePath + path; return (abspath) in goog.dependencies_.deferred; } @@ -1187,7 +1243,7 @@ if (goog.DEPENDENCIES_ENABLED) { if (isDeps) { return false; } else { - throw Error('Cannot write "' + src + '" after document load'); + throw new Error('Cannot write "' + src + '" after document load'); } } @@ -1199,8 +1255,9 @@ if (goog.DEPENDENCIES_ENABLED) { goog.writeScriptSrcNode_(src); } } else { - var state = " onreadystatechange='goog.onScriptLoad_(this, " + - ++goog.lastNonModuleScriptIndex_ + ")' "; + goog.oldIeWaiting_ = true; + var state = ' onreadystatechange=\'goog.onScriptLoad_(this, ' + + ++goog.lastNonModuleScriptIndex_ + ')\' '; doc.write( ' - +