Make the generated Export classes accept undefined
We have constructors, like ol.View2D and ol.control.Attribution, whose "options" argument is optional (opt_options). But currently, we cannot do "new ol.View2D()" in uncompiled code that uses an ol3 build compiled in advanced mode. This commit fixes that by changing the generated Export constructors.
This commit is contained in:
@@ -52,9 +52,16 @@ class Class(Exportable):
|
||||
lines.append(' * @param {%s} options Options.\n' % (self.object_literal.extern_name(),))
|
||||
lines.append(' */\n')
|
||||
lines.append('%sExport = function(options) {\n' % (self.name,))
|
||||
lines.append(' goog.base(this, {')
|
||||
lines.append(' /** @type {%s} */\n' % (self.object_literal.name,))
|
||||
lines.append(' var arg;\n');
|
||||
lines.append(' if (goog.isDefAndNotNull(options)) {\n')
|
||||
lines.append(' arg = {')
|
||||
lines.extend(','.join('\n %s: options.%s' % (key, key) for key in sorted(self.object_literal.prop_types.keys())))
|
||||
lines.append('\n });\n')
|
||||
lines.append('\n };\n')
|
||||
lines.append(' } else {\n')
|
||||
lines.append(' arg = /** @type {%s} */ (options);\n' % (self.object_literal.name,))
|
||||
lines.append(' }\n')
|
||||
lines.append(' goog.base(this, arg);\n')
|
||||
lines.append('};\n')
|
||||
lines.append('goog.inherits(%sExport, %s);\n' % (self.name, self.name))
|
||||
lines.append('goog.exportSymbol(\n')
|
||||
|
||||
Reference in New Issue
Block a user