Example #1
0
 StringMapWrapper.forEach(stringMap, (_, key) => { ListWrapper.push(res, key); });
  /**
   * Return descendant TestElememts matching the given predicate
   * and scope.
   *
   * @param {Function: boolean} predicate
   * @param {Scope} scope
   *
   * @return {List<DebugElement>}
   */
  queryAll(predicate: Predicate<DebugElement>, scope: Function = Scope.all): List<DebugElement> {
    var elementsInScope = scope(this);

    return ListWrapper.filter(elementsInScope, predicate);
  }
 (child) => { scope = ListWrapper.concat(scope, Scope.all(child)); });
Example #4
0
 _createInstances(): List<any> { return ListWrapper.createFixedSize(Key.numberOfKeys + 1); }
Example #5
0
 _setInstance(key: Key, obj): void { ListWrapper.set(this._instances, key.id, obj); }
 addChild(cd: ChangeDetector) {
   ListWrapper.push(this.lightDomChildren, cd);
   cd.parent = this;
 }
 addShadowDomChild(cd: ChangeDetector) {
   ListWrapper.push(this.shadowDomChildren, cd);
   cd.parent = this;
 }
Example #8
0
 _splitBindConfig(bindConfig: string) {
   return ListWrapper.map(bindConfig.split('|'), (s) => s.trim());
 }
Example #9
0
  process(parent: CompileElement, current: CompileElement, control: CompileControl) {
    var attrs = current.attrs();
    var classList = current.classList();

    var cssSelector = new CssSelector();
    var nodeName = DOM.nodeName(current.element);
    cssSelector.setElement(nodeName);
    for (var i = 0; i < classList.length; i++) {
      cssSelector.addClassName(classList[i]);
    }

    MapWrapper.forEach(attrs,
                       (attrValue, attrName) => { cssSelector.addAttribute(attrName, attrValue); });

    var componentDirective;
    var foundDirectiveIndices = [];
    var elementBinder = null;
    this._selectorMatcher.match(cssSelector, (selector, directiveIndex) => {
      elementBinder = current.bindElement();
      var directive = this._directives[directiveIndex];
      if (directive.type === DirectiveMetadata.COMPONENT_TYPE) {
        // components need to go first, so it is easier to locate them in the result.
        ListWrapper.insert(foundDirectiveIndices, 0, directiveIndex);
        if (isPresent(componentDirective)) {
          throw new BaseException(
              `Only one component directive is allowed per element - check ${current.elementDescription}`);
        }
        componentDirective = directive;
        elementBinder.setComponentId(directive.id);
      } else {
        ListWrapper.push(foundDirectiveIndices, directiveIndex);
      }
    });
    ListWrapper.forEach(foundDirectiveIndices, (directiveIndex) => {
      var directive = this._directives[directiveIndex];
      var directiveBinderBuilder = elementBinder.bindDirective(directiveIndex);
      current.compileChildren = current.compileChildren && directive.compileChildren;
      if (isPresent(directive.properties)) {
        MapWrapper.forEach(directive.properties, (bindConfig, dirProperty) => {
          this._bindDirectiveProperty(dirProperty, bindConfig, current, directiveBinderBuilder);
        });
      }
      if (isPresent(directive.hostListeners)) {
        MapWrapper.forEach(directive.hostListeners, (action, eventName) => {
          this._bindDirectiveEvent(eventName, action, current, directiveBinderBuilder);
        });
      }
      if (isPresent(directive.hostActions)) {
        MapWrapper.forEach(directive.hostActions, (action, actionName) => {
          this._bindHostAction(actionName, action, current, directiveBinderBuilder);
        });
      }
      if (isPresent(directive.hostProperties)) {
        MapWrapper.forEach(directive.hostProperties, (hostPropertyName, directivePropertyName) => {
          this._bindHostProperty(hostPropertyName, directivePropertyName, current,
                                 directiveBinderBuilder);
        });
      }
      if (isPresent(directive.hostAttributes)) {
        MapWrapper.forEach(directive.hostAttributes, (hostAttrValue, hostAttrName) => {
          this._addHostAttribute(hostAttrName, hostAttrValue, current);
        });
      }
      if (isPresent(directive.readAttributes)) {
        ListWrapper.forEach(directive.readAttributes,
                            (attrName) => { elementBinder.readAttribute(attrName); });
      }
    });
  }
 _createRecords(definition: ChangeDetectorDefinition) {
   var recordBuilder = new ProtoRecordBuilder();
   ListWrapper.forEach(definition.bindingRecords,
                       (b) => { recordBuilder.add(b, definition.variableNames); });
   return coalesce(recordBuilder.records);
 }
Example #11
0
 StringMapWrapper.forEach(control.errors, (value, error) => {
   if (!StringMapWrapper.contains(res, error)) {
     res[error] = [];
   }
   ListWrapper.push(res[error], control);
 });
function _mapPrimitiveName(keys: List<any>) {
  var stringifiedKeys =
      ListWrapper.join(ListWrapper.map(keys, (k) => isString(k) ? `"${k}"` : `${k}`), ", ");
  return `mapFn([${stringifiedKeys}])`;
}
Example #13
0
 selectableCollector = (selector, context) => {
   ListWrapper.push(matched, selector);
   ListWrapper.push(matched, context);
 };
Example #14
0
 function reset() { matched = ListWrapper.create(); }
Example #15
0
 detachFreeHostView(parentView: viewModule.AppView, hostView: viewModule.AppView) {
   parentView.changeDetector.removeChild(hostView.changeDetector);
   ListWrapper.remove(parentView.freeHostViews, hostView);
 }
Example #16
0
 constructor(groupDirective) {
   this._groupDirective = groupDirective;
   this._directives = ListWrapper.create();
 }
 createSteps(viewDef, subTaskPromises) {
   this.viewDef = viewDef;
   this.subTaskPromises = subTaskPromises;
   ListWrapper.forEach(this.subTaskPromises, (p) => this.subTaskPromises.push(p));
   return this.steps;
 }
Example #18
0
 _updateDomValue() {
   ListWrapper.forEach(this._directives, (cd) => cd._updateDomValue());
 }
 removeChild(cd: ChangeDetector) { ListWrapper.remove(this.lightDomChildren, cd); }
Example #20
0
 addDirective(c) {
   ListWrapper.push(this._directives, c);
 }
 removeShadowDomChild(cd: ChangeDetector) { ListWrapper.remove(this.shadowDomChildren, cd); }
Example #22
0
 (injector: Injector) => ListWrapper.map(childTokens, (token) => injector.get(token)),
Example #23
0
 _getInstance(key: Key) {
   if (this._instances.length <= key.id) return null;
   return ListWrapper.get(this._instances, key.id);
 }
Example #24
0
 /**
  * Starts measuring
  */
 beginMeasure(): Promise<any> {
   return PromiseWrapper.all(ListWrapper.map(this._metrics, (metric) => metric.beginMeasure()));
 }
Example #25
0
function _createListOfBindings(flattenedBindings): List<any> {
  var bindings = ListWrapper.createFixedSize(Key.numberOfKeys + 1);
  MapWrapper.forEach(flattenedBindings, (v, keyId) => bindings[keyId] = v);
  return bindings;
}
Example #26
0
 /**
  * Ends measuring and reports the data
  * since the begin call.
  * @param restart: Whether to restart right after this.
  */
 endMeasure(restart: boolean): Promise<StringMap<string, any>> {
   return PromiseWrapper.all(
                            ListWrapper.map(this._metrics, (metric) => metric.endMeasure(restart)))
       .then((values) => { return mergeStringMaps(values); });
 }
 ListWrapper.forEach(views.views, (nextView) => {
   els = ListWrapper.concat(els, this._getChildElements(nextView, null));
 });
Example #28
0
 indexOf(viewRef: ViewRef): number {
   return ListWrapper.indexOf(this._getViews(), internalView(viewRef));
 }
 ListWrapper.forEach(debugElement.children, (child) => {
   scope.push(child);
   scope = ListWrapper.concat(scope, Scope.light(child));
 });
Example #30
0
 gc(): Promise<any> {
   ListWrapper.push(this._commandLog, ['gc']);
   return PromiseWrapper.resolve(null);
 }