generateAuxiliary(name, params) {
     var pathRecognizer = this.auxNames.get(name);
     if (isBlank(pathRecognizer)) {
         return null;
     }
     return pathRecognizer.generate(params);
 }
 /**
  * Private
  */
 constructor(token, id) {
     this.token = token;
     this.id = id;
     if (isBlank(token)) {
         throw new BaseException('Token must be defined!');
     }
 }
 addChange(changes, oldValue, newValue) {
     if (isBlank(changes)) {
         changes = {};
     }
     changes[this._currentBinding().name] = ChangeDetectionUtil.simpleChange(oldValue, newValue);
     return changes;
 }
 static addChange(changes, propertyName:string, change){
   if (isBlank(changes)) {
     changes = {};
   }
   changes[propertyName] = change;
   return changes;
 }
Пример #5
0
// TODO: vsavkin remove it once https://github.com/angular/angular/issues/3011 is implemented
function selectValueAccessor(dir, valueAccessors) {
    if (lang_1.isBlank(valueAccessors))
        return null;
    var defaultAccessor;
    var builtinAccessor;
    var customAccessor;
    valueAccessors.forEach(function (v) {
        if (lang_1.hasConstructor(v, default_value_accessor_1.DefaultValueAccessor)) {
            defaultAccessor = v;
        }
        else if (lang_1.hasConstructor(v, checkbox_value_accessor_1.CheckboxControlValueAccessor) ||
            lang_1.hasConstructor(v, number_value_accessor_1.NumberValueAccessor) ||
            lang_1.hasConstructor(v, select_control_value_accessor_1.SelectControlValueAccessor) ||
            lang_1.hasConstructor(v, radio_control_value_accessor_1.RadioControlValueAccessor)) {
            if (lang_1.isPresent(builtinAccessor))
                _throwError(dir, "More than one built-in value accessor matches");
            builtinAccessor = v;
        }
        else {
            if (lang_1.isPresent(customAccessor))
                _throwError(dir, "More than one custom value accessor matches");
            customAccessor = v;
        }
    });
    if (lang_1.isPresent(customAccessor))
        return customAccessor;
    if (lang_1.isPresent(builtinAccessor))
        return builtinAccessor;
    if (lang_1.isPresent(defaultAccessor))
        return defaultAccessor;
    _throwError(dir, "No valid value accessor for");
    return null;
}
Пример #6
0
 compileInHost(componentType) {
     var metadatas = reflector.annotations(componentType);
     var hostViewFactory = metadatas.find(isHostViewFactory);
     if (isBlank(hostViewFactory)) {
         throw new BaseException(`No precompiled component ${stringify(componentType)} found`);
     }
     return PromiseWrapper.resolve(new HostViewFactoryRef_(hostViewFactory));
 }
Пример #7
0
 resolve(component) {
     var view = this._cache.get(component);
     if (isBlank(view)) {
         view = this._resolve(component);
         this._cache.set(component, view);
     }
     return view;
 }
Пример #8
0
 _addPartial(map, name) {
     var matcher = MapWrapper.get(map, name);
     if (isBlank(matcher)) {
         matcher = new SelectorMatcher();
         MapWrapper.set(map, name, matcher);
     }
     return matcher;
 }
Пример #9
0
export function normalizeString(obj) {
    if (isBlank(obj)) {
        return null;
    }
    else {
        return obj.toString();
    }
}
 _PendingRequest.prototype.complete = function (response) {
     if (lang_1.isBlank(response)) {
         this.completer.reject("Failed to load " + this.url, null);
     }
     else {
         this.completer.resolve(response);
     }
 };
Пример #11
0
 compileInHost(componentType) {
     var metadatas = reflector.annotations(componentType);
     var compiledHostTemplate = metadatas.find(_isCompiledHostTemplate);
     if (isBlank(compiledHostTemplate)) {
         throw new BaseException(`No precompiled template for component ${stringify(componentType)} found`);
     }
     return PromiseWrapper.resolve(this._createProtoView(compiledHostTemplate));
 }
Пример #12
0
function _createAppInjector(appComponentType: Type, bindings: List<Binding>, zone: VmTurnZone): Injector {
  if (isBlank(_rootInjector)) _rootInjector = Injector.resolveAndCreate(_rootBindings);
  var mergedBindings = isPresent(bindings) ?
      ListWrapper.concat(_injectorBindings(appComponentType), bindings) :
      _injectorBindings(appComponentType);
  ListWrapper.push(mergedBindings, bind(VmTurnZone).toValue(zone));
  return _rootInjector.resolveAndCreateChild(mergedBindings);
}
 ViewResolver.prototype.resolve = function (component) {
     var view = this._cache.get(component);
     if (lang_1.isBlank(view)) {
         view = this._resolve(component);
         this._cache.set(component, view);
     }
     return view;
 };
Пример #14
0
 selectRootElement(selector) {
     var el = DOM.querySelector(this._rootRenderer.document, selector);
     if (isBlank(el)) {
         throw new BaseException(`The selector "${selector}" did not match any elements`);
     }
     DOM.clearNodes(el);
     return el;
 }
Пример #15
0
 ElementInjector.prototype._checkShadowDomAppInjector = function (shadowDomAppInjector) {
     if (this._proto._binding0IsComponent && lang_1.isBlank(shadowDomAppInjector)) {
         throw new lang_1.BaseException('A shadowDomAppInjector is required as this ElementInjector contains a component');
     }
     else if (!this._proto._binding0IsComponent && lang_1.isPresent(shadowDomAppInjector)) {
         throw new lang_1.BaseException('No shadowDomAppInjector allowed as there is not component stored in this ElementInjector');
     }
 };
Пример #16
0
export function convertUrlParamsToArray(urlParams) {
    var paramsArray = [];
    if (isBlank(urlParams)) {
        return [];
    }
    StringMapWrapper.forEach(urlParams, (value, key) => { paramsArray.push((value === true) ? key : key + '=' + value); });
    return paramsArray;
}
function _createVariableNames(parentVariableNames, renderProtoView) {
    var res = lang_1.isBlank(parentVariableNames) ? [] : collection_1.ListWrapper.clone(parentVariableNames);
    collection_1.MapWrapper.forEach(renderProtoView.variableBindings, function (mappedName, varName) { res.push(mappedName); });
    collection_1.ListWrapper.forEach(renderProtoView.elementBinders, function (binder) {
        collection_1.MapWrapper.forEach(binder.variableBindings, function (mappedName, varName) { res.push(mappedName); });
    });
    return res;
}
 transform(value) {
     if (isBlank(value))
         return value;
     if (!isString(value)) {
         throw new InvalidPipeArgumentException(LowerCasePipe_1, value);
     }
     return value.toLowerCase();
 }
Пример #19
0
 bind(appElementToken).toFactory((appComponentAnnotatedType, appDocument) => {
   var selector = appComponentAnnotatedType.annotation.selector;
   var element = DOM.querySelector(appDocument, selector);
   if (isBlank(element)) {
     throw new BaseException(`The app selector "${selector}" did not match any elements`);
   }
   return element;
 }, [appComponentAnnotatedTypeToken, appDocumentToken]),
Пример #20
0
export function createPureProxy(fn, argCount, pureProxyProp, view) {
    view.fields.push(new o.ClassField(pureProxyProp.name, null, [o.StmtModifier.Private]));
    var pureProxyId = argCount < Identifiers.pureProxies.length ? Identifiers.pureProxies[argCount] : null;
    if (isBlank(pureProxyId)) {
        throw new BaseException(`Unsupported number of argument for pure functions: ${argCount}`);
    }
    view.createMethod.addStmt(o.THIS_EXPR.prop(pureProxyProp.name).set(o.importExpr(pureProxyId).callFn([fn])).toStmt());
}
Пример #21
0
 _ParseAST.prototype.error = function (message, index) {
     if (index === void 0) { index = null; }
     if (lang_1.isBlank(index))
         index = this.index;
     var location = (index < this.tokens.length) ? "at column " + (this.tokens[index].index + 1) + " in" :
         "at the end of the expression";
     throw new ParseException(message, this.input, location, this.location);
 };
  get(url: string): Promise<string> {
    var response = MapWrapper.get(this._responses, url);
    if (isBlank(response)) {
      return PromiseWrapper.reject('xhr error', null);
    }

    return PromiseWrapper.resolve(response);
  }
Пример #23
0
 /** @internal */
 _registerView(value, view) {
     var views = this._valueViews.get(value);
     if (isBlank(views)) {
         views = [];
         this._valueViews.set(value, views);
     }
     views.push(view);
 }
Пример #24
0
 complete(response) {
     if (isBlank(response)) {
         this.completer.reject(`Failed to load ${this.url}`, null);
     }
     else {
         this.completer.resolve(response);
     }
 }
Пример #25
0
 _addTerminal(map, name, selectable) {
     var terminalList = MapWrapper.get(map, name);
     if (isBlank(terminalList)) {
         terminalList = ListWrapper.create();
         MapWrapper.set(map, name, terminalList);
     }
     ListWrapper.push(terminalList, selectable);
 }
Пример #26
0
 renderComponent(componentProto) {
     var renderer = this._registeredComponents.get(componentProto.id);
     if (isBlank(renderer)) {
         renderer = new DomRenderer(this, componentProto);
         this._registeredComponents.set(componentProto.id, renderer);
     }
     return renderer;
 }
Пример #27
0
 UpperCasePipe.prototype.transform = function (value) {
     if (lang_1.isBlank(value))
         return value;
     if (!lang_1.isString(value)) {
         throw new invalid_pipe_argument_exception_1.InvalidPipeArgumentException(UpperCasePipe, value);
     }
     return value.toUpperCase();
 };
Пример #28
0
 NgSwitch.prototype._registerView = function (value, view) {
     var views = this._valueViews.get(value);
     if (lang_1.isBlank(views)) {
         views = [];
         this._valueViews.set(value, views);
     }
     views.push(view);
 };
Пример #29
0
 StringMapWrapper.forEach(appEl.proto.directiveVariableBindings, (directiveIndex, name) => {
     if (isBlank(directiveIndex)) {
         localsMap.set(name, appEl.nativeElement);
     }
     else {
         localsMap.set(name, appEl.getDirectiveAtIndex(directiveIndex));
     }
 });
Пример #30
0
 collection_1.StringMapWrapper.forEach(appEl.proto.directiveVariableBindings, function (directiveIndex, name) {
     if (lang_1.isBlank(directiveIndex)) {
         localsMap.set(name, appEl.nativeElement);
     }
     else {
         localsMap.set(name, appEl.getDirectiveAtIndex(directiveIndex));
     }
 });