Remove all goog.asserts and goog.isXxx

First step to reducing Closure’s footprint.
This commit is contained in:
Neil Fraser
2018-06-10 00:15:22 -07:00
committed by Neil Fraser
parent 02dc7b1d1d
commit 3909bd420a
35 changed files with 251 additions and 205 deletions

View File

@@ -35,7 +35,6 @@ goog.provide('Blockly.Extensions');
goog.require('Blockly.Mutator');
goog.require('Blockly.utils');
goog.require('goog.string');
/**
* The set of all registered extensions, keyed by extension name/id.
@@ -54,13 +53,13 @@ Blockly.Extensions.ALL_ = {};
* registered, or extensionFn is not a function.
*/
Blockly.Extensions.register = function(name, initFn) {
if (!goog.isString(name) || goog.string.isEmptyOrWhitespace(name)) {
if ((typeof name != 'string') || (name.trim() == '')) {
throw new Error('Error: Invalid extension name "' + name + '"');
}
if (Blockly.Extensions.ALL_[name]) {
throw new Error('Error: Extension "' + name + '" is already registered.');
}
if (!goog.isFunction(initFn)) {
if (typeof initFn != 'function') {
throw new Error('Error: Extension "' + name + '" must be a function');
}
Blockly.Extensions.ALL_[name] = initFn;
@@ -74,7 +73,7 @@ Blockly.Extensions.register = function(name, initFn) {
* registered.
*/
Blockly.Extensions.registerMixin = function(name, mixinObj) {
if (!goog.isObject(mixinObj)){
if (!mixinObj || typeof mixinObj != 'object'){
throw new Error('Error: Mixin "' + name + '" must be a object');
}
Blockly.Extensions.register(name, function() {
@@ -108,7 +107,7 @@ Blockly.Extensions.registerMutator = function(name, mixinObj, opt_helperFn,
var hasMutatorDialog =
Blockly.Extensions.checkMutatorDialog_(mixinObj, errorPrefix);
if (opt_helperFn && !goog.isFunction(opt_helperFn)) {
if (opt_helperFn && (typeof opt_helperFn != 'function')) {
throw new Error('Extension "' + name + '" is not a function');
}
@@ -136,7 +135,7 @@ Blockly.Extensions.registerMutator = function(name, mixinObj, opt_helperFn,
*/
Blockly.Extensions.apply = function(name, block, isMutator) {
var extensionFn = Blockly.Extensions.ALL_[name];
if (!goog.isFunction(extensionFn)) {
if (typeof extensionFn != 'function') {
throw new Error('Error: Extension "' + name + '" not found.');
}
if (isMutator) {