diff --git a/core/shortcut_registry.ts b/core/shortcut_registry.ts index 795a57c73..7bb7f035e 100644 --- a/core/shortcut_registry.ts +++ b/core/shortcut_registry.ts @@ -299,9 +299,8 @@ export class ShortcutRegistry { * @throws {Error} if the modifier is not in the valid modifiers list. */ private checkModifiers_(modifiers: KeyCodes[]) { - const validModifiers = object.values(ShortcutRegistry.modifierKeys); for (let i = 0, modifier; modifier = modifiers[i]; i++) { - if (validModifiers.indexOf(modifier) < 0) { + if (!(modifier in ShortcutRegistry.modifierKeys)) { throw new Error(modifier + ' is not a valid modifier key.'); } } diff --git a/core/utils/deprecation.ts b/core/utils/deprecation.ts index 5c4b959f6..af2800fb3 100644 --- a/core/utils/deprecation.ts +++ b/core/utils/deprecation.ts @@ -18,10 +18,10 @@ goog.declareModuleId('Blockly.utils.deprecation'); * Warn developers that a function or property is deprecated. * * @param name The name of the function or property. - * @param deprecationDate The date of deprecation. - * Prefer 'month yyyy' or 'quarter yyyy' format. - * @param deletionDate The date of deletion, in the same format as the - * deprecation date. + * @param deprecationDate The date of deprecation. Prefer 'version n.0.0' + * format, and fall back to 'month yyyy' or 'quarter yyyy' format. + * @param deletionDate The date of deletion. Prefer 'version n.0.0' + * format, and fall back to 'month yyyy' or 'quarter yyyy' format. * @param opt_use The name of a function or property to use instead, if any. * @alias Blockly.utils.deprecation.warn * @internal @@ -29,8 +29,8 @@ goog.declareModuleId('Blockly.utils.deprecation'); export function warn( name: string, deprecationDate: string, deletionDate: string, opt_use?: string) { - let msg = name + ' was deprecated on ' + deprecationDate + - ' and will be deleted on ' + deletionDate + '.'; + let msg = name + ' was deprecated in ' + deprecationDate + + ' and will be deleted in ' + deletionDate + '.'; if (opt_use) { msg += '\nUse ' + opt_use + ' instead.'; } diff --git a/core/utils/object.ts b/core/utils/object.ts index 42cb59c22..e094ec612 100644 --- a/core/utils/object.ts +++ b/core/utils/object.ts @@ -24,6 +24,8 @@ import * as deprecation from './deprecation.js'; * @alias Blockly.utils.object.inherits */ export function inherits(childCtor: Function, parentCtor: Function) { + deprecation.warn( + 'Blockly.utils.object.inherits', 'version 9.0.0', 'version 10.0.0'); // Set a .superClass_ property so that methods can call parent methods // without hard-coding the parent class name. // Could be replaced by ES6's super(). @@ -86,11 +88,8 @@ export function deepMerge( * @alias Blockly.utils.object.values */ export function values(obj: AnyDuringMigration): AnyDuringMigration[] { - if (Object.values) { - return Object.values(obj); - } - // Fallback for IE. - return Object.keys(obj).map(function(e) { - return obj[e]; - }); + deprecation.warn( + 'Blockly.utils.object.values', 'version 9.0.0', 'version 10.0.0', + 'Object.values'); + return Object.values(obj); }